0
Why is my perfect square detection code not working?
4 Respuestas
+ 1
var rt= function sqr(num){
return num;
}
{ } were missing
+ 1
your logic is not working
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>
- 1
Thanks but unfortunately my code is still not working but I changed it like you said