From 2b3bd5c52d33ecd83b2f716a99ecacfc39914888 Mon Sep 17 00:00:00 2001 From: Ty Mick Date: Mon, 18 May 2020 11:24:54 -0400 Subject: [PATCH] Improve formatting and clarity in "Subset" (#38814) * Improve formatting and clarity in "Subset" * Change method name to isSubsetOf Co-authored-by: Eric Leung * Change method name to isSubsetOf Co-authored-by: Eric Leung * Fix method name in tests * Fix variable name aIsSubsetOfB * Fix method name in solution Co-authored-by: Eric Leung --- ...ubset-check-on-two-sets-of-data.english.md | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/curriculum/challenges/english/08-coding-interview-prep/data-structures/perform-a-subset-check-on-two-sets-of-data.english.md b/curriculum/challenges/english/08-coding-interview-prep/data-structures/perform-a-subset-check-on-two-sets-of-data.english.md index c2ff098f24..98e55cf99d 100644 --- a/curriculum/challenges/english/08-coding-interview-prep/data-structures/perform-a-subset-check-on-two-sets-of-data.english.md +++ b/curriculum/challenges/english/08-coding-interview-prep/data-structures/perform-a-subset-check-on-two-sets-of-data.english.md @@ -7,8 +7,8 @@ forumTopicId: 301707 ## Description
-In this exercise we are going to perform a subset test on 2 sets of data. We will create a method on our Set data structure called subset. This will compare the first set, against the second and if the first set is fully contained within the Second then it will return true. -For example, if setA = ['a','b'] and setB = ['a','b','c','d'], then the subset of setA and setB is: setA.subset(setB) should be true. +In this exercise, we are going to perform a subset test on 2 sets of data. We will create a method on our Set data structure called isSubsetOf. This will compare the first set against the second, and if the first set is fully contained within the second, it will return true. +For example, if setA = ['a','b'] and setB = ['a','b','c','d'], then setA is a subset of setB, so setA.isSubsetOf(setB) should return true.
## Instructions @@ -21,18 +21,18 @@ For example, if setA = ['a','b'] and setB = ['a','b','c','d'] ```yml tests: - - text: Your Set class should have a subset method. - testString: assert((function(){var test = new Set(); return (typeof test.subset === 'function')})()); + - text: Your Set class should have a isSubsetOf method. + testString: assert((function(){var test = new Set(); return (typeof test.isSubsetOf === 'function')})()); - text: The first Set() should be contained in the second Set - testString: assert((function(){var setA = new Set(); var setB = new Set(); setA.add('a'); setB.add('b'); setB.add('c'); setB.add('a'); setB.add('d'); var subsetSetAB = setA.subset(setB);return (subsetSetAB === true)})()); - - text: ['a', 'b'].subset(['a', 'b', 'c', 'd']) should return true - testString: assert((function(){var setA = new Set(); var setB = new Set(); setA.add('a'); setA.add('b'); setB.add('a'); setB.add('b'); setB.add('c'); setB.add('d'); var subsetSetAB = setA.subset(setB); return (subsetSetAB === true)})()); - - text: ['a', 'b', 'c'].subset(['a', 'b']) should return false - testString: assert((function(){var setA = new Set(); var setB = new Set(); setA.add('a'); setA.add('b'); setA.add('c'); setB.add('a'); setB.add('b'); var subsetSetAB = setA.subset(setB); return (subsetSetAB === false)})()); - - text: [].subset([]) should return true - testString: assert((function(){var setA = new Set(); var setB = new Set(); var subsetSetAB = setA.subset(setB); return (subsetSetAB === true)})()); - - text: ['a', 'b'].subset(['c', 'd']) should return false - testString: assert((function(){var setA = new Set(); var setB = new Set(); setA.add('a'); setA.add('b'); setB.add('c'); setB.add('d'); var subsetSetAB = setA.subset(setB); return (subsetSetAB === false)})()); + testString: assert((function(){var setA = new Set(); var setB = new Set(); setA.add('a'); setB.add('b'); setB.add('c'); setB.add('a'); setB.add('d'); var aIsSubsetOfB = setA.isSubsetOf(setB);return (aIsSubsetOfB === true)})()); + - text: ['a', 'b'].isSubsetOf(['a', 'b', 'c', 'd']) should return true + testString: assert((function(){var setA = new Set(); var setB = new Set(); setA.add('a'); setA.add('b'); setB.add('a'); setB.add('b'); setB.add('c'); setB.add('d'); var aIsSubsetOfB = setA.isSubsetOf(setB); return (aIsSubsetOfB === true)})()); + - text: ['a', 'b', 'c'].isSubsetOf(['a', 'b']) should return false + testString: assert((function(){var setA = new Set(); var setB = new Set(); setA.add('a'); setA.add('b'); setA.add('c'); setB.add('a'); setB.add('b'); var aIsSubsetOfB = setA.isSubsetOf(setB); return (aIsSubsetOfB === false)})()); + - text: [].isSubsetOf([]) should return true + testString: assert((function(){var setA = new Set(); var setB = new Set(); var aIsSubsetOfB = setA.isSubsetOf(setB); return (aIsSubsetOfB === true)})()); + - text: ['a', 'b'].isSubsetOf(['c', 'd']) should return false + testString: assert((function(){var setA = new Set(); var setB = new Set(); setA.add('a'); setA.add('b'); setB.add('c'); setB.add('d'); var aIsSubsetOfB = setA.isSubsetOf(setB); return (aIsSubsetOfB === false)})()); ``` @@ -223,7 +223,7 @@ class Set { return newSet; } - subset(set) { + isSubsetOf(set) { for(const value of this.values()){ if(!set.dictionary[value]) return false; }