0
Umm why isn't this working
I'm trying to make a multiplication calculator but its not working can you tell me why? var n = prompt("Enter a number", ""); var multiply; var answer = Math.multiply(n); alert("The answer " + n + " is " + answer);
6 odpowiedzi
+ 4
Assuming it's JavaScript, n is a string. Multiply requires 2 or more arguments and can't process strings. Try this:
var n = parseInt(prompt("Enter a number", ""));
var answer = math.multiply(n, n);
alert("The answer " + n + " is " + answer);
+ 2
math.js that defines multiply needs to be include as it isn't a standard part of JavaScript. Personally, I'd just do n*n or whatever you're looking for.
+ 1
Okay thank you.
+ 1
yay! it works now
0
yea it's java script I guess I left that out
0
but I keep getting the multiply is not a function error