Problems | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Problems

Whenever I use the ^2 exponent in Javascript, no matter what the base is, the answer is always 2. 100^2 = 2 5^2 = 2 1^2 = 2 Any ideas how/why this is happening?

3rd Jun 2018, 6:29 PM
Norberttony
Norberttony - avatar
5 Answers
+ 1
3rd Jun 2018, 7:04 PM
Max
Max - avatar
+ 7
is this what you're looking for? Math.pow(5, 2)
3rd Jun 2018, 6:45 PM
MCJEH
MCJEH - avatar
+ 6
when I tried it inside an alert function I got 102
3rd Jun 2018, 7:10 PM
MCJEH
MCJEH - avatar
+ 2
or 5**2
3rd Jun 2018, 6:52 PM
Roel
Roel - avatar
0
Hmmm, I was so used to using ^ for exponents. Thanks for the help!
5th Jun 2018, 12:33 AM
Norberttony
Norberttony - avatar