I am new to javascript and taking some tests on codewars, I am writing a code that checks for perfect numbers i.e. if a number has a squareroot that is a whole number it should return true. Here is my code and it only works for 0 and 1, from here it returns false even for numbers that are perfect squares. I need to understand why my code is not working and i cannot see where my problem is.
var isSquare = function(n){
for ( var i=0; i>=0; i++){
var product= i*i;
if( product === n )
return true;
else if(product !==n)
return false;
}
}