I know that when you use the math.random() that it generates a random value with many places : 5.6938506849, and I need it to just generate two decimal value: 5.69. How do I do this, here is a portion of the code:
//problem 1
var num1a = (Math.random()* 10) + 1;
var num1b = (Math.random()* 10) + 1;
var product1 = num1a * num1b;
var response = parseFloat(prompt("What is the product of " + num1a + " and " + num1b + " ?"));
if (response == product1)
{
count1 = count1 + 1;
result = "correct!";
alert(result);
}
else
{
result = "incorrect";
alert(result);
}
if (count1 == 3)
{
levelTwo();
return;
}
Thank you!
//problem 1
var num1a = (Math.random()* 10) + 1;
var num1b = (Math.random()* 10) + 1;
var product1 = num1a * num1b;
var response = parseFloat(prompt("What is the product of " + num1a + " and " + num1b + " ?"));
if (response == product1)
{
count1 = count1 + 1;
result = "correct!";
alert(result);
}
else
{
result = "incorrect";
alert(result);
}
if (count1 == 3)
{
levelTwo();
return;
}
Thank you!