Skip to content

Instantly share code, notes, and snippets.

@McLarenCollege
Last active October 6, 2022 11:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save McLarenCollege/01d961c1a9cc84ea89448214291e8f3b to your computer and use it in GitHub Desktop.
Save McLarenCollege/01d961c1a9cc84ea89448214291e8f3b to your computer and use it in GitHub Desktop.
Exercise : Unique In Order

Unique In Order

Implement the function uniqueInOrder which takes as argument a string or array and returns an array of items with the repeated elements removed.

For example:

function uniqueInOrder(input){
// write your code here
}
console.log(uniqueInOrder('AAAABBBCCDAABBB'));//  ['A', 'B', 'C', 'D', 'A', 'B']
console.log(uniqueInOrder('ABBCcAD'));// ['A', 'B', 'C', 'c', 'A', 'D']
console.log(uniqueInOrder([1,2,2,3,3]));// [1,2,3]

Please watch this video for a hint for the problem.

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