var discount = Math.floor((Math.random()*5) + 5); Closed due to the fact that the essence of the issue is incomprehensible by the participants of Kromster , Alexey Shimansky , insolor , user207618, AK ♦ Jun 20 '17 at 15:31 .
Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .
1 answer
Math.random() function generates a random number in the range [0;1)
i.e., 0 <= Math.random() < 1
multiply by 5, we get: 0 <= Math.random()*5 < 5
add 5, we get: 5 <= (Math.random()*5) + 5 < 10
the Math.floor() function retrieves the integer part of a number (according to help, returns the largest integer that is less than or equal to the argument),
accordingly, a random number in the range [5;9] (from 5 to 9, including both borders) will be written to the variable discount
floorandrandomfunctions. The course of arithmetic is difficult? - teran*and+and the signs(,)and=? - Igor