Advertisement
Guest User

Untitled

a guest
Jul 29th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. var $ = require('jquery')
  2. require('cycle-shell')(main, {
  3. welcome: `Hello play the number game 1 to 456`
  4. })
  5.  
  6. setBackgroundColor(`darkblue`)
  7.  
  8. var answer = getRandomNumber(456)
  9.  
  10. function main (input) {
  11. if (input === answer){
  12. return`correct good for you`
  13. }else{
  14. return renderHint(input)
  15. }
  16. }
  17.  
  18. function renderHint (guess){
  19. if(guess>answer){
  20. return`Hint:too high try again`
  21. }else{
  22. return`Hint:it's too low try again`
  23. }
  24. }
  25.  
  26. function getRandomNumber (max){
  27. return Math.floor(Math.random() *max) + 1
  28. }
  29.  
  30. function setBackgroundColor (color) {
  31. setTimeout(function() {
  32. $(`.app`).css(`background`,color)
  33. }, 50)
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement