Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loop Case #2

Open
tholman opened this issue Apr 27, 2017 · 0 comments
Open

Loop Case #2

tholman opened this issue Apr 27, 2017 · 0 comments

Comments

@tholman
Copy link

tholman commented Apr 27, 2017

var isSquare = function(arr){
  var num = 0;
if (arr.length < 1) {
  return undefined;
};
for (var i = 0; i < arr.length; i++) {
  for (var x = 0; x < arr[i]; x++) {
    if (arr[i] === 1) {
      num += 1;
    } else if (x * x === arr[i]) {
      num += 1;
    }
  }
};
  if (num === arr.length) {
    return true;
  } else {
    return false;
  }
};
console.log(isSquare([1, 4, 9, 16, 25, 36, 225, 7225, 9604, 5563518921]));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant