Why does my Log say the Value is NaN?

well, i have this part of my code inside the js now everytime the loop runs it's supposed to generate a random value for x , y , vX , vY and r but when I log the value inside the loop it says all those variables r NaN this is the part
for(let i=0; i<100; i++){

x = Math.random * innerWidth;
y = Math.random * innerHeight;
vX = Math.random * 10 - 5;
vY = Math.random * 20 - 10;
r = Math.random * 30;
console.log(x);

circleArray.push(new Circle(x,y,vX,vY,r));

}
for(let i=0; i<100; i++){

x = Math.random * innerWidth;
y = Math.random * innerHeight;
vX = Math.random * 10 - 5;
vY = Math.random * 20 - 10;
r = Math.random * 30;
console.log(x);

circleArray.push(new Circle(x,y,vX,vY,r));

}
and this is the codepen https://codepen.io/-bloop-/pen/bGxRpmw tnx!!
14 Replies
Jochem
Jochem•16mo ago
That part isn't in the linked codepen, but Math.random isn't a value, it's a function
glutonium
glutonium•16mo ago
i deleted the previous code and inputted it i think i need to save it I don't use codepen so Idk can u try it rn? i saved the new code
Jochem
Jochem•16mo ago
you can also just make a new one, you can make quite a lot
glutonium
glutonium•16mo ago
ahahah..okee
Jochem
Jochem•16mo ago
yup, this works:
x = Math.random() * innerWidth;

y = Math.random() * innerHeight;

vX = Math.random() * 10 - 5;

vY = Math.random() * 20 - 10;

r = Math.random() * 30;
x = Math.random() * innerWidth;

y = Math.random() * innerHeight;

vX = Math.random() * 10 - 5;

vY = Math.random() * 20 - 10;

r = Math.random() * 30;
glutonium
glutonium•16mo ago
ooh wait lmaao
Jochem
Jochem•16mo ago
you have to call random, it's not just a value you can use
glutonium
glutonium•16mo ago
I didn't add the parentheses ;-; sorry
Jochem
Jochem•16mo ago
no worries, stuff like this happens to everyone, no matter how long you've been programming 😄
glutonium
glutonium•16mo ago
works..ty xD
glutonium
glutonium•16mo ago
@jochemm how is it xD
glutonium
glutonium•16mo ago
canvas is kinda fun
Jochem
Jochem•16mo ago
looks good! I've never really played with canvas, I know you can do some wild things with it
glutonium
glutonium•16mo ago
ahaha yee