Skip to content

Loop Case #2

Open
Open
@tholman

Description

@tholman
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]));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions