From 0973091ac59aee80810257e91e40f896f6026d63 Mon Sep 17 00:00:00 2001 From: Manish Date: Wed, 23 Aug 2023 11:19:19 +1000 Subject: [PATCH] Data Structures: Use .has and .size on an ES6 Set --- Data Structures/es6SetHasAndSize.js | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 Data Structures/es6SetHasAndSize.js diff --git a/Data Structures/es6SetHasAndSize.js b/Data Structures/es6SetHasAndSize.js new file mode 100644 index 0000000..d4e1e39 --- /dev/null +++ b/Data Structures/es6SetHasAndSize.js @@ -0,0 +1,8 @@ +// https://www.freecodecamp.org/learn/coding-interview-prep/data-structures/use--has-and--size-on-an-es6-set + +function checkSet(arrToBeSet, checkValue) { + // Only change code below this line + const set = new Set(arrToBeSet); + return [set.has(checkValue), set.size]; + // Only change code above this line +}