diff --git a/week-1-project/app.js b/week-1-project/app.js index 5fdfbea..3144611 100644 --- a/week-1-project/app.js +++ b/week-1-project/app.js @@ -3,41 +3,131 @@ const object = { NaNyStrings: [], isNumberyString: function (param) { // write me! + + if (typeof param !== 'string') { + return false; + } + + return !isNaN(param); }, addString: function (param) { - if (null) return false; // write this early return condition - - // write me! (using this.isNumberyString) + if (typeof param !== "string"){ + return false; + }else if (isNaN(param)){ + this.NaNyStrings.push(param); + }else if(!isNaN(param)){ + this.numberyStrings.push(param); + } + return true; + + }, allStrings: function () { // write me! + if (this.NaNyStrings.length===0){ + return this.numberyStrings; + }else if(this.numberyStrings.length===0){ + return this.NaNyStrings; + } + return this.numberyStrings.concat(this.NaNyStrings); }, evenStrings: function () { // write me! + if (this.NaNyStrings.length !== 0 && this.numberyStrings.length === 0) { + return this.numberyStrings; + }else if (this.NaNyStrings.length === 0 && this.numberyStrings.length !== 0){ + function even(num){ + return (num % 2 === 0); + } + return this.numberyStrings.filter(even); + }else if (this.NaNyStrings.length !== 0 && this.numberyStrings.length !== 0){ + function even(num){ + return (num % 2 === 0); + } + return this.numberyStrings.filter(even); + } }, oddStrings: function () { // write me! + if (this.NaNyStrings.length !== 0 && this.numberyStrings.length === 0){ + return this.numberyStrings; + }else if (this.NaNyStrings.length === 0 && this.numberyStrings.length !== 0){ + function odd(num){ + return (num%2 !== 0); + } + return this.numberyStrings.filter(odd); + }else if (this.NaNyStrings.length !== 0 && this.numberyStrings.length !== 0){ + function odd(num){ + return (num % 2 !== 0); + } + return this.numberyStrings.filter(odd); + } }, negativeStrings: function () { // write me! + if (this.NaNyStrings.length !== 0 && this.numberyStrings.length === 0){ + return this.numberyStrings; + }else if (this.NaNyStrings.length === 0 && this.numberyStrings.length !== 0){ + function negative(num){ + return (num < 0); + } + return this.numberyStrings.filter(negative); + }else if (this.NaNyStrings.length !== 0 && this.numberyStrings.length !== 0){ + function negative(num){ + return (num < 0); + } + return this.numberyStrings.filter(negative); + } }, positiveStrings: function () { // write me! + if (this.NaNyStrings.length !== 0 && this.numberyStrings.length === 0){ + return this.numberyStrings; + }else if (this.NaNyStrings.length === 0 && this.numberyStrings.length !== 0){ + function positive(num){ + return (num > 0); + } + return this.numberyStrings.filter(positive); + }else if (this.NaNyStrings.length !== 0 && this.numberyStrings.length !== 0){ + function positive(num){ + return (num > 0 || num === ""); + } + return this.numberyStrings.filter(positive); + } }, zeroStrings: function () { // write me! + if (this.NaNyStrings.length !== 0 && this.numberyStrings.length === 0){ + return this.numberyStrings; + }else if (this.NaNyStrings.length === 0 && this.numberyStrings.length !== 0){ + function zero(num){ + return (num == 0); + } + return this.numberyStrings.filter(zero); + }else if (this.NaNyStrings.length !== 0 && this.numberyStrings.length !== 0){ + function zero(num){ + return (num == 0); + } + return this.numberyStrings.filter(zero); + } }, numberyAsNumbers: function () { // write me! + return this.numberyStrings.map(num => Number(num)); + }, NaNyAsNumbers: function () { // write me! + return this.NaNyStrings.map( num => Number(num)); }, sumOfNumbery: function () { - // write me! (using a Array.prototype.reduce()) + // write me! + const reducer = (accumulator, currentValue) => Number(accumulator) + Number(currentValue); + return this.numberyStrings.reduce(reducer, 0); }, sumOfNaNy: function () { // write me! + return NaN; }, }; diff --git a/week-1-project/practice-problems/avoiding-side-effects.js b/week-1-project/practice-problems/avoiding-side-effects.js index 823001d..eb68855 100644 --- a/week-1-project/practice-problems/avoiding-side-effects.js +++ b/week-1-project/practice-problems/avoiding-side-effects.js @@ -170,6 +170,14 @@ try { ]; function replaceItem(arr, index, newItem) { // write me! + /*function repeatItems(items, numRepeats) { + let result = items.map(e => { + let arr1=[]; + let filled = arr1.fill(e, 0, numRepeats) + return filled; + }); + return result;*/ + } replaceItem.display = true; evaluate(replaceItem, replaceItemTests); diff --git a/week-2-project/app.js b/week-2-project/app.js index 90e883b..6a250d7 100644 --- a/week-2-project/app.js +++ b/week-2-project/app.js @@ -15,72 +15,112 @@ const object = { entries: {}, isPrimitive: function (value) { // write me! + if (Object(value) !== value) { + return true + } + else { + return false + } }, hasKey: function (obj, key) { // write me! + return (obj.hasOwnProperty(key)); }, hasValue: function (obj, value) { // write me! + if(Object.values(obj).includes(value)) { + return true + } + else { + return false + } }, addEntry: function (key, value) { - if (null) { // write me! + if (typeof key !== "string") { // write me! return new TypeError('addEntry: key should be a string'); } - if (null) { // write me! (using this.isPrimitive) + if (!this.isPrimitive(value)) { // write me! (using this.isPrimitive) return new TypeError('addEntry: value should be a primitive'); } - if (null) { // write me! (using this.hasKey) + if (this.hasKey(this.entries, key)) { // write me! (using this.hasKey) return new Error(`addEntry: key "${key}" already exists`); } - + else (this.entries[key] = value);{ + return true + } // write me! }, removeEntry: function (key) { - if (null) { // write me! + if (typeof key !== "string") { // write me! return new TypeError('removeEntry: key should be a string'); } - if (null) { // write me! (using this.hasKey) + if (!this.hasKey(this.entries, key)) { // write me! (using this.hasKey) return new ReferenceError(`removeEntry: no property "${key}" in this.entries`); } - - delete this.entries[key] - return true - // write me! + delete this.entries[key]; + return true; + }, + updateEntry: function (key, value) { - if (null) { // write me! + if (typeof key !== "string") { // write me! return new TypeError('updateEntry: key should be a string'); } - if (null) { // write me! (using this.isPrimitive) + if (!this.isPrimitive(value)) { // write me! (using this.isPrimitive) return new TypeError('updateEntry: value should be a primitive'); } - if (null) { // write me! (using this.hasKey) + if (!this.hasKey(this.entries, key)) { // write me! (using this.hasKey) return new ReferenceError(`updateEntry: no property "${key}" in this.entries`); } - + else { + (this.entries[key] = value); + return true; + } // write me! }, readAll: function () { // write me! + var readObj = {... this.entries}; + return readObj; + }, findByKey: function (key) { - if (null) { // write me! + if (typeof key !== 'string') { // write me! return new TypeError('findByKey: key should be a string'); } - if (null) { // write me! (using this.hasKey) + if (!this.hasKey(this.entries, key)) { // write me! (using this.hasKey) + console.log('haskey'); return new ReferenceError(`findByKey: no property "${key}" in this.entries`); } - - // write me! + + const newObj = {}; + newObj[key] = this.entries[key]; + return newObj; // write me! }, + + copyEntries: function() { + let copied = {...this.entries}; + return copied; + }, + + findByValue: function (value) { - if (null) { // write me! (using this.isPrimitive) + if (!this.isPrimitive(value)) { // write me! (using this.isPrimitive) return new TypeError('findByValue: value should be a primitive'); } - if (null) { // write me! (using this.hasValue) + if (!this.hasValue(this.entries, value)) { // write me! (using this.hasValue) return new ReferenceError(`findByValue: no entry with value (${typeof value}, ${value})`); } - - // write me! (this one is a bit trickier) + + let copiedEntries = this.copyEntries(); + let requestedObj={}; + let newKey = Object.keys(copiedEntries).filter(keyOfValue => copiedEntries[keyOfValue] === value); + for (let i = 0; i < newKey.length; i++) { + if (this.entries[newKey[i]] === value) { + requestedObj[newKey[i]] = value; + } + } + return requestedObj; + // write me! (this one is a bit trickier) }, } diff --git a/week-2-project/practice-problems/objects.js b/week-2-project/practice-problems/objects.js index be4dbb3..3f6acad 100644 --- a/week-2-project/practice-problems/objects.js +++ b/week-2-project/practice-problems/objects.js @@ -137,12 +137,12 @@ try { // -- const index = 'y'; - ; // write one line to pass the assertions + a1[index] = 'roof!'; // write one line to pass the assertions console.assert(a1[index] === a2[index], 'a1[index] should strictly equal a2[index]'); console.assert(a1[index] === 'roof!', 'a1[index] should strictly equal "roof!"'); - ; // write two lines to pass the assertions - ; + b1[index] = 'floor!'; // write two lines to pass the assertions + b2[index] = b1[index]; console.assert(b1[index] === b2[index], 'b1[index] should strictly equal b2[index]'); console.assert(b1[index] === 'floor!', 'b1[index] should strictly equal "floor!"'); @@ -155,33 +155,35 @@ try { const value1 = 5; let reference1 = {}; - ; // write this line + let value2=value1; // write this line console.assert(value2 === value1, "value1 should strictly equal value2"); - ; // write this line + let reference2=reference1; // write this line console.assert(reference2 === reference1, "reference1 should strictly equal reference2"); value2 = value2 + 1; // write this line - console.assert(value1 !== null, "value1 should strictly equal ___"); + console.assert(value1 !== null, "value1 should strictly equal 5"); - ; // write this line + reference1.x = reference2.x = 'hi!'; // write this line console.assert(reference1.x === reference2.x, "references.x should be strictly equal"); console.assert(reference1.x === 'hi!', "references.x should strictly equal 'hi!'"); - ; // write this line + reference1=reference2; // write this line console.assert(reference1 === reference2, "references should be strictly equal"); // remove the object from memory - ; // write this line - ; // write this line + reference1=null; // write this line + reference2=null; // write this line } evaluate(passTheAssertions2); function passTheAssertions3() { - ; // write this line - ; // write this line + let obj1 = {}; + let obj2 = {}; + obj1.y = obj2.y = 'B'; + obj1.x = obj2.x = 'A'; console.assert(obj1 !== obj2, 'the variables should not be strictly equal'); console.assert(obj1.y === obj2.y, 'their first entries should be the same'); console.assert(obj1.y === 'B', 'obj1.y should be "B"'); @@ -190,18 +192,18 @@ try { console.assert(obj1[index] === obj2[index], 'obj1[index] should strictly equal obj2[index]'); console.assert(obj1[index] === 'A', 'obj1[index] should be "A"'); - ; // write this line - ; // write this line + obj2.z = obj1.z = 'y'; // write this line + obj[obl2.z] === obj2[obj1.z]; // write this line console.assert(obj1[obj2.z] === 'B', 'obj2.z should be "B"s index in obj1'); console.assert(obj1[obj2.z] === obj2[obj1.z], 'some tricky nested thing should be true'); - ; // write this line + let obj3 = obj2; // write this line console.assert(obj1 !== obj2, 'obj1 should strictly equal obj2'); console.assert(obj3 !== obj1, 'obj3 should not strictly equal obj`'); console.assert(obj3 === obj2, 'obj3 should strictly equal obj2'); console.assert(obj3[index] === obj1.x, 'obj3[index] should strictly equal obj1.x'); - ; // write this line + obj3.z = obj2.x; // write this line console.assert(obj3.z === obj2[index], 'obj3.z should strictly equal obj2[index]'); } evaluate(passTheAssertions3); diff --git a/week-2-project/practice-problems/using-objects.js b/week-2-project/practice-problems/using-objects.js index 9f29459..0988d47 100644 --- a/week-2-project/practice-problems/using-objects.js +++ b/week-2-project/practice-problems/using-objects.js @@ -12,8 +12,8 @@ try { const obj = { a: 0, - getA: function () { }, - sumAB: function (b) { }, + getA: function () {return this.a }, + sumAB: function (b) {return this.a +b }, }; console.assert(obj.getA() === 0, '1: obj.getA() should return 0'); @@ -36,8 +36,14 @@ try { const obj = { word: '', - getWord: function () { }, - concat: function (secondHalf) { }, + getWord: function () { + if (typeof this.word === 'string'){ + return "the word is " + this.word + }else { + return this.word; + } + }, + concat: function (secondHalf) { return this.word.concat(secondHalf) }, }; console.assert(obj.getWord() === 'the word is ', `1: obj.getWord() should return 'the word is '`); @@ -94,8 +100,8 @@ try { const obj = { string: '', - setString: function (str) { }, - remixString: function (mixer) { } + setString: function (str) { this.string = str}, + remixString: function (mixer) { this.string = this.string.split('').join(mixer) } } obj.setString('hoy'); diff --git a/week-2-project/tests/remove-entry.js b/week-2-project/tests/remove-entry.js index 8a14f0c..f02b5e8 100644 --- a/week-2-project/tests/remove-entry.js +++ b/week-2-project/tests/remove-entry.js @@ -38,7 +38,11 @@ describe(`removeEntry: should remove a key/value pair from this.entries`, () => describe(`... and actually removes the entries!`, () => { valuesToRemove.forEach(arg => { it(`object.hasKey(object.entries, ${arg}) === false`, () => { +<<<<<<< HEAD + assert.strictEqual(this.entries.hasOwnProperty(arg), false); +======= assert.strictEqual(object.entries.hasOwnProperty(arg), false); +>>>>>>> upstream/master }); }); }); diff --git a/week-3-project/app.js b/week-3-project/app.js index b4fe84f..7356092 100644 --- a/week-3-project/app.js +++ b/week-3-project/app.js @@ -1,16 +1,17 @@ const object = { currentKey: '', set currentEntry(key) { - if (null) { // write the early return condition + if (typeof key !== 'string' ) { // write the early return condition throw new TypeError('set currentEntry: key should be a string'); } - if (null) { // write the early return condition + if (!this.entries.hasOwnProperty(key)) { // write the early return condition throw new ReferenceError(`set currentEntry: no entry with key "${key}"`); } - - // write me! + this.currentEntry = key; // write me! + }, get currentEntry() { + return this.entries[this.currentKey]; // write me! }, likedKeys: [], @@ -43,31 +44,78 @@ const object = { }, entries: {}, isPrimitive: function (value) { - // write me! + if (Object(value) !== value) {return true}; + return false; // write me! }, hasKey: function (obj, key) { - // write me! + return (obj.hasOwnProperty(key)); }, hasValue: function (obj, value) { - // write me! + if(Object.values(obj).includes(value)) {return true}; + return false; // write me! }, addEntry: function (key, value) { - // write me! + if (typeof key !== 'string') { + return new TypeError('addEntry: key should be a string'); + } else if (!this.isPrimitive(value)) { + return new TypeError('addEntry: value should be a primitive'); + } else if (this.hasKey(this.entries, key)) { + return new Error(`addEntry: key "${key}" already exists`); + } else {this.entries[key] = value; + return true;} // write me! }, removeEntry: function (key) { - // write me! + if (typeof key !== 'string') { + return new TypeError('removeEntry: key should be a string'); + } else if (!this.hasKey(this.entries, key)) { + return new ReferenceError(`removeEntry: no property "${key}" in this.entries`); + } + delete this.entries[key]; + return true; // write me! }, updateEntry: function (key, value) { - // write me! + if (typeof key !== 'string') { + return new TypeError('updateEntry: key should be a string'); + } else if (!this.isPrimitive(value)) { + return new TypeError('updateEntry: value should be a primitive'); + } else if (!this.hasKey(this.entries, key)) { + return new ReferenceError(`updateEntry: no property "${key}" in this.entries`); + } else {this.entries[key] = value; + return true;} // write me! }, readAll: function () { - // write me! + let clonedObj = {...this.entries}; + return clonedObj; // write me! }, findByKey: function (key) { - // write me! + if (typeof key !== 'string') { + return new TypeError('findByKey: key should be a string'); + } else if (!this.hasKey(this.entries, key)) { + return new ReferenceError(`findByKey: no property "${key}" in this.entries`); + } + const newObj = {}; + newObj[key] = this.entries[key]; + return newObj; // write me! + }, + copyEntries: function() { + let copied = {...this.entries}; + return copied; }, findByValue: function (value) { - // write me! + if (!this.isPrimitive(value)) { + return new TypeError('findByValue: value should be a primitive'); + } else if (!this.hasValue(this.entries, value)) { + return new ReferenceError(`findByValue: no entry with value (${typeof value}, ${value})`); + } + let copiedEntries = this.copyEntries(); + let requestedObj={}; + let newKey = Object.keys(copiedEntries).filter(keyOfValue => copiedEntries[keyOfValue] === value); + for (let i = 0; i < newKey.length; i++) { + if (this.entries[newKey[i]] === value) { + requestedObj[newKey[i]] = value; + } + } + return requestedObj;// write me! }, } diff --git a/week-3-project/practice-problems/arrays-vs-objects.js b/week-3-project/practice-problems/arrays-vs-objects.js index 4a7e82c..f6caf3a 100644 --- a/week-3-project/practice-problems/arrays-vs-objects.js +++ b/week-3-project/practice-problems/arrays-vs-objects.js @@ -17,7 +17,9 @@ try { let _ = null; // swap the values stored in each structure - + _ = obj.prop; + obj.prop = arr[0]; + arr[0] = _ ; console.assert(obj.prop === "object", "obj.prop should be 'object"); console.assert(arr[0] === "array", "arr[0] should be 'array"); @@ -33,10 +35,15 @@ try { const objKey = 'prop'; const arrIndex = 0; + _ = obj[objKey]; + obj[objKey] = arr[arrIndex]; + arr[arrIndex] = _ ; + + // asserts - console.assert(obj[obj_key] === "object", "obj assert"); - console.assert(arr[arr_index] === "array", "arr assert"); + console.assert(obj[objKey] === "object", "obj assert"); + console.assert(arr[arrIndex] === "array", "arr assert"); } evaluate(swapValues2); @@ -54,6 +61,8 @@ try { const arr2 = [3, 2, 1]; const arr3 = [1, 2, 3]; // do you remember why '===' won't work here? + arr2[0] = 1; + arr2[2] = 3; console.assert(evaluate.compareValues(arr1, arr2), 'arr: same values, different order'); console.assert(evaluate.compareValues(arr1, arr3), 'arr: same values, same order'); diff --git a/week-3-project/practice-problems/error-based-decisions.js b/week-3-project/practice-problems/error-based-decisions.js index f0b2f66..2504617 100644 --- a/week-3-project/practice-problems/error-based-decisions.js +++ b/week-3-project/practice-problems/error-based-decisions.js @@ -35,10 +35,12 @@ try { function exercise1(arg) { const result = mightReturnAnError(arg); - if (null) { // write this condition - // write me! + // debugger; + + if (result instanceof Error) { // write this condition + return false;// write me! } else { - // write me! + return true;// write me! } } @@ -59,10 +61,15 @@ try { ] function exercise2(arg) { const result = mightReturnAnError(arg); + + if (result instanceof Error) { // write this condition + return result.message;// write me! + } else { + return arg;// write me! + } - // write me! - - } + + } exercise2.display = true; evaluate(exercise2, exercise2Tests); @@ -81,10 +88,13 @@ try { ] function exercise3(arg) { const result = mightReturnAnError(arg); - - // write me! - - } + if (result instanceof Error) { + return {[typeof arg] : (result.message)}; + } else { + return {[typeof arg] : arg}; + } + + } exercise3.display = true; evaluate(exercise3, exercise3Tests); @@ -102,9 +112,13 @@ try { ] function exercise4(arg) { const result = mightReturnAnError(arg); + if (result instanceof Error){ + return [result.message]; + }else { + return [ null, arg]; + } - // write me! - + } exercise4.display = true; evaluate(exercise4, exercise4Tests); @@ -120,5 +134,4 @@ try { { console.groupEnd(); - document.body.appendChild(document.createElement('hr')); -} + document.body.appendChild(document.createElement('hr'))} diff --git a/week-3-project/practice-problems/getters-and-setters.js b/week-3-project/practice-problems/getters-and-setters.js index c5f2609..84015b0 100644 --- a/week-3-project/practice-problems/getters-and-setters.js +++ b/week-3-project/practice-problems/getters-and-setters.js @@ -27,14 +27,14 @@ try { const obj2 = { name: 'obj2', get greeting() { - // write me! + return `hi, I'm ${this.name}`; } } const obj1Greeting1 = obj1.getGreeting(); console.assert(obj1Greeting1 === `hi, I'm obj1`, `obj1's greeting is correct (1)`); - const obj2Greeting1 = null; // fix this line! + const obj2Greeting1 = obj2.greeting; // fix this line! console.assert(obj2Greeting1 === `hi, I'm obj2`, `obj2's greeting is correct (1)`); obj1.name = "first"; @@ -43,7 +43,7 @@ try { const obj1Greeting2 = obj1.getGreeting(); console.assert(obj1Greeting2 === `hi, I'm first`, `obj1's greeting is correct (2)`); - const obj2Greeting2 = null; // fix this line! + const obj2Greeting2 = obj2.greeting; // fix this line! console.assert(obj2Greeting2 === `hi, I'm second`, `obj2's greeting is correct (2)`); } @@ -65,16 +65,16 @@ try { numbers: [12, 4, 9, 36, 7, 0, -2], modulo: 3, get zeroMods() { - // write me! + return this.numbers.filter(x => x % this.modulo === 0); // write me! } } - const obj1mods3 = null; + const obj1mods3 = obj1.getZeroMods(); console.assert(obj1mods3[0] === 12, 'assert 1'); console.assert(obj1mods3[1] === 9, 'assert 2'); console.assert(obj1mods3[2] === 36, 'assert 3'); - const obj2mods3 = null; + const obj2mods3 = obj2.zeroMods; console.assert(obj2mods3[0] === 12, 'assert 4'); console.assert(obj2mods3[1] === 9, 'assert 5'); console.assert(obj2mods3[2] === 36, 'assert 6'); @@ -83,11 +83,11 @@ try { obj1.modulo = 6; obj2.modulo = 6; - const obj1mods3second = null; + const obj1mods3second = obj1.getZeroMods(); console.assert(obj1mods3second[0] === 12, 'assert 7'); console.assert(obj1mods3second[1] === 36, 'assert 8'); - const obj2mods3second = null; + const obj2mods3second = obj2.zeroMods; console.assert(obj2mods3second[0] === 12, 'assert 9'); console.assert(obj2mods3second[1] === 36, 'assert 10'); @@ -110,25 +110,25 @@ try { entries: { first: 'hi!', second: 'bye!' }, currentKey: 'second', get currentEntry() { - // write me! + return this.entries[this.currentKey];// write me! } } // replace the null's to pass the asserts: - const obj1current1 = null; + const obj1current1 = obj1.getCurrentEntry(); console.assert(obj1current1 === 'bye!', 'assert 1'); - const obj2current1 = null; + const obj2current1 = obj2.currentEntry; console.assert(obj2current1 === 'bye!', 'assert 2'); - obj1.currentKey = null; - obj2.currentKey = null; + obj1.currentKey = obj1.entries['first']; + obj2.currentKey = obj2.entries['first']; - const obj1current2 = null; + const obj1current2 = obj1.currentKey; console.assert(obj1current2 === 'hi!', 'assert 3'); - const obj2current2 = null; + const obj2current2 = obj2.currentKey; console.assert(obj2current2 === 'hi!', 'assert 4'); } @@ -149,20 +149,20 @@ try { const obj2 = { greeting: ``, set greetingName(newName) { - // write me! + this.greeting = `hi, I'm ${newName}!`; // write me! } }; obj1.setGreetingName('obj1'); console.assert(obj1.greeting === "hi, I'm obj1!", 'assert 1'); - ; // write me! + obj2.greetingName = 'obj2'; // write me! console.assert(obj2.greeting === "hi, I'm obj2!", 'assert 2'); obj1.setGreetingName('hi'); console.assert(obj1.greeting === "hi, I'm hi!", 'assert 3'); - ; // write me! + obj2.greetingName = "bye"; // write me! console.assert(obj2.greeting === "hi, I'm bye!", 'assert 4'); } @@ -197,13 +197,19 @@ try { const obj2 = { entries: { first: 'hi!', second: 'bye!' }, current: {}, - // write me! + set currentEntry(key) { + if (this.entries.hasOwnProperty(key)) { + this.current = { [key]: this.entries[key] }; + } else { + this.current = { [key]: new Error(`no entry with key "${key}"`) } + } + }// write me! } obj1.setCurrentEntry('second'); console.assert(obj1.current.second === "bye!", 'assert 1'); - ; // write me! + obj2.currentEntry = 'second'; // write me! console.assert(obj2.current.second === "bye!", 'assert 2'); @@ -211,7 +217,7 @@ try { console.assert(obj1.current.first === "hi!", 'assert 3'); console.assert(obj1.current.hasOwnProperty('second') === false, 'assert 4'); - ; // write me! + obj2.currentEntry = 'first'; // write me! console.assert(obj2.current.first === "hi!", 'assert 5'); console.assert(obj2.current.hasOwnProperty('second') === false, 'assert 6'); @@ -220,7 +226,7 @@ try { console.assert(obj1.current.hi.message === 'no entry with key "hi"', 'assert 7'); console.assert(obj1.current.hasOwnProperty('first') === false, 'assert 8'); - ; // write me! + obj2.currentEntry = 'hi'; // write me! console.assert(obj2.current.hi.message === 'no entry with key "hi"', 'assert 9'); console.assert(obj2.current.hasOwnProperty('first') === false, 'assert 10');