numbers-methods.js 716 B

1234567891011121314151617181920212223242526272829
  1. let num = 103.941
  2. console.log(num.toFixed(2))
  3. console.log(Math.round(num))
  4. console.log(Math.floor(num)) //round down to nearest integer
  5. console.log(Math.ceil(num)) //round up
  6. //let randomNum = Math.random()
  7. //console.log(randomNum) // between 0 and 0.999
  8. // let min = 10
  9. // let max = 20
  10. // let randomNum = Math.floor(Math.random() * (max - min + 1)) + min// floor( 10 to 10.999 )
  11. // //0 to 10
  12. // console.log(randomNum)
  13. // Challenge area
  14. // 1 - 5 - true if correct - false if not correct
  15. let makeGuess = function (guess) {
  16. let min = 1
  17. let max = 5
  18. let randomNum = Math.floor(Math.random() * (max - min + 1)) + min
  19. console.log(randomNum)
  20. return guess === randomNum
  21. }
  22. console.log(makeGuess(1))