0

Why is my perfect square detection code not working?

https://code.sololearn.com/WwKrOs0K2l2o/?ref=app

22nd Apr 2017, 1:46 AM
AceDev
4 ответов
+ 1
var rt= function sqr(num){ return num; } { } were missing
22nd Apr 2017, 2:04 AM
LordHill
LordHill - avatar
+ 1
your logic is not working
22nd Apr 2017, 2:27 AM
Calviղ
Calviղ - avatar
0
I see you got it working without the function. if you want the function back, I don't know JS, but this seems to work <!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body><script>var num=prompt("What is ur age?"); var num= parseFloat(num); var age=num; var myFunc= function(x){ return Math.sqrt(x); } var rt= myFunc(num); if (rt*rt==age){ alert("Ur age is a perfect square!") ; }</script> </body> </html>
22nd Apr 2017, 2:40 AM
LordHill
LordHill - avatar
- 1
Thanks but unfortunately my code is still not working but I changed it like you said
22nd Apr 2017, 2:19 AM
AceDev