Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save phillypb/03d8043cd093f72bea026ad2dcf5aa47 to your computer and use it in GitHub Desktop.
Save phillypb/03d8043cd093f72bea026ad2dcf5aa47 to your computer and use it in GitHub Desktop.
/*
Function to sort through an array of duplicates, to then create a new array of
unique values.
*/
function sortArray() {
// array to sort
var messyArray = ['A', 'B', 'A', 'C', 'B', 'B', 'B'];
// JavaScript 'Set' used to go through and create new unique array
var uniqueArray = [
...new Set(messyArray)
];
// log the unique array
Logger.log(uniqueArray);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment