Skip to content

Instantly share code, notes, and snippets.

@MarcusHurney
Created February 13, 2017 00:23
Show Gist options
  • Save MarcusHurney/6798cb6bc105438d103019ae6138ec60 to your computer and use it in GitHub Desktop.
Save MarcusHurney/6798cb6bc105438d103019ae6138ec60 to your computer and use it in GitHub Desktop.
let sortedArray = [0, 1, 1, 2, 4, 18, 23, 23, 28, 30, 30, 30];
let withoutDuplicates = [0, 1, 2, 4, 18, 23, 28, 30];
function checkDuplicates(array) {
var newArray = [];
for (var i = 0; i < array.length; i++) {
if (array[i] !== array[i + 1]) {
newArray.push(array[i]);
}
}
return newArray;
}
console.log(checkDuplicates(sortedArray));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment