Created
February 1, 2023 10:21
-
-
Save phillypb/03d8043cd093f72bea026ad2dcf5aa47 to your computer and use it in GitHub Desktop.
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
/* | |
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