diff --git a/challenges/08-coding-interview-questions-and-take-home-assignments/coding-interview-data-structure-questions.json b/challenges/08-coding-interview-questions-and-take-home-assignments/coding-interview-data-structure-questions.json index b855c353f9..43520b8492 100644 --- a/challenges/08-coding-interview-questions-and-take-home-assignments/coding-interview-data-structure-questions.json +++ b/challenges/08-coding-interview-questions-and-take-home-assignments/coding-interview-data-structure-questions.json @@ -230,7 +230,8 @@ "
var set = new Object();", "In the next few exercises, we will build a full featured Set from scratch.", "For this exercise, create a function that will add a value to our set collection as long as the value does not already exist in the set. For example:", - "
set.foo = true;
// See if foo exists in our set:
console.log(set.foo) // true
this.add = function(element) {" + "
//some code to add value to the set
}
this.add = function(element) {", + "The function should return
//some code to add value to the set
}
true
if the value is successfully added and false
otherwise."
],
"challengeSeed": [
"function Set() {",
@@ -250,7 +251,9 @@
],
"tests": [
"assert((function(){var test = new Set(); return (typeof test.add === 'function')}()), 'message: Your Set
class should have a add
method.');",
- "assert((function(){var test = new Set(); test.add('a'); test.add('b'); test.add('a'); var vals = test.values(); console.log(vals); return (vals[0] === 'a' && vals[1] === 'b' && vals.length === 2)}()), 'message: Your Set
should not add duplicate values.');"
+ "assert((function(){var test = new Set(); test.add('a'); test.add('b'); test.add('a'); var vals = test.values(); console.log(vals); return (vals[0] === 'a' && vals[1] === 'b' && vals.length === 2)}()), 'message: Your Set
should not add duplicate values.');",
+ "assert((function(){var test = new Set(); var result = test.add('a'); return (result != undefined) && (result === true);}()), 'message: Your Set
should return true
when a value has been successfully added.');",
+ "assert((function(){var test = new Set(); test.add('a'); var result = test.add('a'); return (result != undefined) && (result === false);}()), 'message: Your Set
should return false
when the user tries to add a duplicate value.');"
],
"type": "waypoint",
"solutions": [],