freeCodeCamp/Data Structures/es6SetAdd.js

13 lines
394 B
JavaScript
Raw Permalink Normal View History

// 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();