Using Variable to Multiply Math.random()

javascript, random

Solution

`Math.random()` returns a number between 0 and 1 and you are `floor`ing it so multiplying it by 1 wont get you anything but 0 when you `floor()` it.

Problem

I need to multiply the Math.random() method with a variable. Example: ``` a = 2; b = Math.floor(Math.random()*a); alert(b); ``` This however doesn't do anything. Is there a specific way I need to write it? If not then why will the javascript alert if I put alert(b); or something of the like.

Original source