Skip to content

Instantly share code, notes, and snippets.

@tobi-bams
Created April 10, 2021 09:54
Show Gist options
  • Save tobi-bams/5412600091334d19843600c91bb3dba5 to your computer and use it in GitHub Desktop.
Save tobi-bams/5412600091334d19843600c91bb3dba5 to your computer and use it in GitHub Desktop.
A Function that removes duplicate values from a sorted Array
const removeDuplicates = (sortedArray) => {
const filteredArray = [];
sortedArray.forEach((num)=> {
if(!filteredArray.includes(num)) {
filteredArray.push(num);
}
});
return filteredArray.length;
}
@tobi-bams
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment