Advertisement
Guest User

Untitled

a guest
Jul 24th, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. //Create a file called helpers.js
  2. //Add the following code:
  3. module.exports = function () {
  4.  
  5. /**
  6. * Returns a random integer between min (inclusive) and max (inclusive)
  7. * Using Math.round() will give you a non-uniform distribution!
  8. */
  9. global.getRandomInt = function (min, max) {
  10. return Math.floor(Math.random() * (max - min + 1)) + min;
  11. }
  12.  
  13. global.random_greeting = [
  14. 'Greetings new friend.',
  15. "Hello there!",
  16. "Having fun I hope?",
  17. "Glad we've met.",
  18. "Happy to help!"
  19. ]
  20. }
  21.  
  22. //In app.js include the following code:
  23. require('./helpers.js')();
  24.  
  25. //Then in the dialog section, add this:
  26. var randint = getRandomInt(0, random_greeting.length-1);
  27.  
  28. //To display the random greeting, then add something like this:
  29. .text(random_greeting[randint] +" This is Yaddops' Geography Chatbot")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement