Created
February 13, 2017 00:23
-
-
Save MarcusHurney/6798cb6bc105438d103019ae6138ec60 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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