From 4cf17a74255756f5495a0aaf9c933bc6abfebd3b Mon Sep 17 00:00:00 2001 From: Manish Date: Wed, 23 Aug 2023 11:13:50 +1000 Subject: [PATCH] Data Structures: Create and Add to Sets in ES6 --- Data Structures/es6SetAdd.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 Data Structures/es6SetAdd.js diff --git a/Data Structures/es6SetAdd.js b/Data Structures/es6SetAdd.js new file mode 100644 index 0000000..211191c --- /dev/null +++ b/Data Structures/es6SetAdd.js @@ -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();