Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
var 11 = [Math.floor(Math.random()*100)] var 22 = [Math.floor(Math.random()*100)] var 33 = [Math.floor(Math.random()*100)] var 44 = [Math.floor(Math.random()*100)] I have a variable "11" and I want to remove its fractional value. For example, for the variable 11 to be equal to 3.14 instead of 3.14. |
||||
|
Your question isnt clear - this statement doesnt make sense: "For example, for the variable 11 to be equal to 3.14 instead of 3.14." I would not use brackets around math calculations - incorrect syntax. use something like this if you want from 0 - 99. var number = Math.floor(Math.random()*100); If you want 1- 100 just add 1 to the end result. |
||||
|
Robo wrote: Your question isnt clear - this statement doesnt make sense: "For example, for the variable 11 to be equal to 3.14 instead of 3.14." I would not use brackets around math calculations - incorrect syntax. use something like this if you want from 0 - 99. var number = Math.floor(Math.random()*100); If you want 1- 100 just add 1 to the end result. I need the numbers after the dot to be removed. for example, if the variable x is equal to 3.004, then after executing the command, it will simply be equal to 3 |
||||
|
easy - use Math.round(put variable in here); |
|