Skip to content

Instantly share code, notes, and snippets.

@tamunoibi
Last active April 30, 2019 19:36
Show Gist options
  • Select an option

  • Save tamunoibi/14e2c02d32ac4aeb2644c3a32f5e3b48 to your computer and use it in GitHub Desktop.

Select an option

Save tamunoibi/14e2c02d32ac4aeb2644c3a32f5e3b48 to your computer and use it in GitHub Desktop.
//This returns true if the number is repeated
function isRepeated(num) {
let unique = [];
let numArr = num.toString()
.split('');
for (var i = 0; i < numArr.length; i++) {
//if the number is not already in unique, push it to unique
if (unique.indexOf(numArr[i]) === -1) {
unique.push(numArr[i]);
} else {
return true;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment