Created
April 10, 2021 09:54
-
-
Save tobi-bams/5412600091334d19843600c91bb3dba5 to your computer and use it in GitHub Desktop.
A Function that removes duplicate values from a sorted Array
This file contains 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
const removeDuplicates = (sortedArray) => { | |
const filteredArray = []; | |
sortedArray.forEach((num)=> { | |
if(!filteredArray.includes(num)) { | |
filteredArray.push(num); | |
} | |
}); | |
return filteredArray.length; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you so much @meekg33k, i really appreciate the feedback.
I have gone through the solutions and have seen what i could have done better.
I hope to do better this week and make sure i consider edge cases when writing code.
I really appreciate and thanks for organizing this.