Inbuilt function


#1

what is the use of Math.floor and what does math.floor(math.random()) does please explain me any one


#2

floor floors the number (rounds down), so math.floor(math.random()) will floor a random number


#3

math.random has 0 to 1 why should it be rounded


#4

true, but this is introduced in steps so next time we can generate a random number one of the following random numbers: 0, 1, 2, 3 or 4 with the following code:

math.floor(math.random() * 5)

#5

thank u i understood now


#6

can you give me a demo example of Math.floor(math.random())
like math.floor() first then math.floor(math.ramdom()) plz


#7

why does demo example mean?

You can just experiment with code within the lessons (or outside the lessons like on jsbin), to study code further

furthermore, you can check external docs, MDN always has good docs:


#8

i'm sorry but how would math.floor(math.rando()*5) can give 2,3,4,5
math.random() varies from 0-1 floor(0.33) gives 0 right how can we get 2,3,4,5


#9

math.random()*5 happens first, so lets say math.random generates 0.7 we get 0.7 * 5 which is 3.5, which will floor to 3


#10

oh thank you i got it pretty clear this time
can you suggest what is a demanded programming language now a days and coming 4 yrs probably


#11

plenty, JS with html and css (front-end), JS for back-end even, python, Java and more

stackoverflow always has surveys:

in includes job tasks, language and basicly everything you need to know