numbers-methods.js 663 B

123456789101112131415161718192021222324252627
  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)) // 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 randomNum = Math.ceil(Math.random()* (4 + 1))
  17. console.log(randomNum)
  18. return guess === randomNum
  19. }
  20. console.log(makeGuess(1))