Data Structures: Create and Add to Sets in ES6

This commit is contained in:
Manish 2023-08-23 11:13:50 +10:00
parent 91f24f96e6
commit 4cf17a7425

View File

@ -0,0 +1,12 @@
// https://www.freecodecamp.org/learn/coding-interview-prep/data-structures/create-and-add-to-sets-in-es6
function checkSet() {
var set = new Set([1, 2, 3, 3, 2, 1, 2, 3, 1]);
// Only change code below this line
[1, 2, 3, "Taco", "Cat", "Awesome"].forEach((element) => set.add(element));
// Only change code above this line
console.log(Array.from(set));
return set;
}
checkSet();