Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Create a file called helpers.js
- //Add the following code:
- module.exports = function () {
- /**
- * Returns a random integer between min (inclusive) and max (inclusive)
- * Using Math.round() will give you a non-uniform distribution!
- */
- global.getRandomInt = function (min, max) {
- return Math.floor(Math.random() * (max - min + 1)) + min;
- }
- global.random_greeting = [
- 'Greetings new friend.',
- "Hello there!",
- "Having fun I hope?",
- "Glad we've met.",
- "Happy to help!"
- ]
- }
- //In app.js include the following code:
- require('./helpers.js')();
- //Then in the dialog section, add this:
- var randint = getRandomInt(0, random_greeting.length-1);
- //To display the random greeting, then add something like this:
- .text(random_greeting[randint] +" This is Yaddops' Geography Chatbot")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement