A student in correctly attempted to produce a random value in the range 1.6 using the expression.

6* ( int ) Math.random ( ) + 1

Correct the error in expression above to get the desired result.

Please answer it ASAP ​

Respuesta :

Answer:

The answer to this question is given below in the explanation section

Explanation:

This is a javascript function.  To return a value between the range of two numbers, we can use the following function "getRandom" that takes a minimum value and maximum value.

function getRandom(min, max) {

 return Math.random() * (max - min) + min;

}

However, the correct code to produce a random value in the range of 1 to 6 using expression is :

Math.random() * (6-1) + 1;

this line of code return random number in rand of 1 to 6.