diff --git a/curriculum/challenges/english/03-front-end-development-libraries/redux/copy-an-object-with-object.assign.md b/curriculum/challenges/english/03-front-end-development-libraries/redux/copy-an-object-with-object.assign.md index e1067263123..74b01b9cc79 100644 --- a/curriculum/challenges/english/03-front-end-development-libraries/redux/copy-an-object-with-object.assign.md +++ b/curriculum/challenges/english/03-front-end-development-libraries/redux/copy-an-object-with-object.assign.md @@ -25,18 +25,14 @@ The Redux state and actions were modified to handle an `object` for the `state`. The Redux store should exist and initialize with a state that is equivalent to the `defaultState` object declared on line 1. ```js -assert( - (function () { - const expectedState = { - user: 'CamperBot', - status: 'offline', - friends: '732,982', - community: 'freeCodeCamp' - }; - const initialState = store.getState(); - return DeepEqual(expectedState, initialState); - })() -); +const expectedState = { + user: 'CamperBot', + status: 'offline', + friends: '732,982', + community: 'freeCodeCamp' +}; +const initialState = store.getState(); +assert.deepEqual(expectedState, initialState); ``` `wakeUp` and `immutableReducer` both should be functions. @@ -48,21 +44,19 @@ assert(typeof wakeUp === 'function' && typeof immutableReducer === 'function'); Dispatching an action of type `ONLINE` should update the property `status` in state to `online` and should NOT mutate state. ```js -assert( - (function () { - const initialState = store.getState(); - const isFrozen = DeepFreeze(initialState); - store.dispatch({ type: 'ONLINE' }); - const finalState = store.getState(); - const expectedState = { - user: 'CamperBot', - status: 'online', - friends: '732,982', - community: 'freeCodeCamp' - }; - return isFrozen && DeepEqual(finalState, expectedState); - })() -); + +const initialState = store.getState(); +const isFrozen = !!DeepFreeze(initialState); +store.dispatch({ type: 'ONLINE' }); +const finalState = store.getState(); +const expectedState = { + user: 'CamperBot', + status: 'online', + friends: '732,982', + community: 'freeCodeCamp' +}; +assert(isFrozen); +assert.deepEqual(finalState, expectedState); ``` `Object.assign` should be used to return new state. diff --git a/curriculum/challenges/english/03-front-end-development-libraries/redux/never-mutate-state.md b/curriculum/challenges/english/03-front-end-development-libraries/redux/never-mutate-state.md index 002a7c4da28..1b7d885ecef 100644 --- a/curriculum/challenges/english/03-front-end-development-libraries/redux/never-mutate-state.md +++ b/curriculum/challenges/english/03-front-end-development-libraries/redux/never-mutate-state.md @@ -48,22 +48,19 @@ assert(typeof addToDo === 'function' && typeof immutableReducer === 'function'); Dispatching an action of type `ADD_TO_DO` on the Redux store should add a `todo` item and should NOT mutate state. ```js -assert( - (function () { - const initialState = store.getState(); - const isFrozen = DeepFreeze(initialState); - store.dispatch(addToDo('__TEST__TO__DO__')); - const finalState = store.getState(); - const expectedState = [ - 'Go to the store', - 'Clean the house', - 'Cook dinner', - 'Learn to code', - '__TEST__TO__DO__' - ]; - return isFrozen && DeepEqual(finalState, expectedState); - })() -); +const initialState = store.getState(); +const isFrozen = !!DeepFreeze(initialState); +store.dispatch(addToDo('__TEST__TO__DO__')); +const finalState = store.getState(); +const expectedState = [ + 'Go to the store', + 'Clean the house', + 'Cook dinner', + 'Learn to code', + '__TEST__TO__DO__' +]; +assert(isFrozen); +assert.deepEqual(finalState, expectedState); ``` # --seed-- diff --git a/curriculum/challenges/english/03-front-end-development-libraries/redux/remove-an-item-from-an-array.md b/curriculum/challenges/english/03-front-end-development-libraries/redux/remove-an-item-from-an-array.md index 16bd461669b..6cd6880d146 100644 --- a/curriculum/challenges/english/03-front-end-development-libraries/redux/remove-an-item-from-an-array.md +++ b/curriculum/challenges/english/03-front-end-development-libraries/redux/remove-an-item-from-an-array.md @@ -19,15 +19,9 @@ The reducer and action creator were modified to remove an item from an array bas The Redux store should exist and initialize with a state equal to `[0,1,2,3,4,5]` ```js -assert( - (function () { - const initialState = store.getState(); - return ( - Array.isArray(initialState) === true && - DeepEqual(initialState, [0, 1, 2, 3, 4, 5]) - ); - })() -); +const initialState = store.getState(); +assert.isArray(initialState) +assert.deepEqual(initialState, [0, 1, 2, 3, 4, 5]) ``` `removeItem` and `immutableReducer` both should be functions. @@ -41,26 +35,22 @@ assert( Dispatching the `removeItem` action creator should remove items from the state and should NOT mutate state. ```js -assert( - (function () { - const initialState = store.getState(); - const isFrozen = DeepFreeze(initialState); - store.dispatch(removeItem(3)); - const state_1 = store.getState(); - store.dispatch(removeItem(2)); - const state_2 = store.getState(); - store.dispatch(removeItem(0)); - store.dispatch(removeItem(0)); - store.dispatch(removeItem(0)); - const state_3 = store.getState(); - return ( - isFrozen && - DeepEqual(state_1, [0, 1, 2, 4, 5]) && - DeepEqual(state_2, [0, 1, 4, 5]) && - DeepEqual(state_3, [5]) - ); - })() -); +const initialState = store.getState(); +const isFrozen = !!DeepFreeze(initialState); +store.dispatch(removeItem(3)); +const state_1 = store.getState(); +store.dispatch(removeItem(2)); +const state_2 = store.getState(); +store.dispatch(removeItem(0)); +store.dispatch(removeItem(0)); +store.dispatch(removeItem(0)); +const state_3 = store.getState(); + +assert(isFrozen) +assert.deepEqual(state_1, [0, 1, 2, 4, 5]) +assert.deepEqual(state_2, [0, 1, 4, 5]) +assert.deepEqual(state_3, [5]) + ``` # --seed-- diff --git a/curriculum/challenges/english/03-front-end-development-libraries/redux/use-the-spread-operator-on-arrays.md b/curriculum/challenges/english/03-front-end-development-libraries/redux/use-the-spread-operator-on-arrays.md index 607dc1ca430..9caf0bb9ffb 100644 --- a/curriculum/challenges/english/03-front-end-development-libraries/redux/use-the-spread-operator-on-arrays.md +++ b/curriculum/challenges/english/03-front-end-development-libraries/redux/use-the-spread-operator-on-arrays.md @@ -45,16 +45,13 @@ assert(typeof addToDo === 'function' && typeof immutableReducer === 'function'); Dispatching an action of type `ADD_TO_DO` on the Redux store should add a `todo` item and should NOT mutate state. ```js -assert( - (function () { - const initialState = store.getState(); - const isFrozen = DeepFreeze(initialState); - store.dispatch(addToDo('__TEST__TO__DO__')); - const finalState = store.getState(); - const expectedState = ['Do not mutate state!', '__TEST__TO__DO__']; - return isFrozen && DeepEqual(finalState, expectedState); - })() -); +const initialState = store.getState(); +const isFrozen = !!DeepFreeze(initialState); +store.dispatch(addToDo('__TEST__TO__DO__')); +const finalState = store.getState(); +const expectedState = ['Do not mutate state!', '__TEST__TO__DO__']; +assert(isFrozen) +assert.deepEqual(finalState, expectedState); ``` The spread operator should be used to return new state. diff --git a/curriculum/challenges/english/10-coding-interview-prep/data-structures/perform-a-difference-on-two-sets-of-data.md b/curriculum/challenges/english/10-coding-interview-prep/data-structures/perform-a-difference-on-two-sets-of-data.md index 8c40ae51616..1411cad0d08 100644 --- a/curriculum/challenges/english/10-coding-interview-prep/data-structures/perform-a-difference-on-two-sets-of-data.md +++ b/curriculum/challenges/english/10-coding-interview-prep/data-structures/perform-a-difference-on-two-sets-of-data.md @@ -28,22 +28,17 @@ assert( Your `difference` method should return the proper collection. ```js -assert( - (function () { - var setA = new Set(); - var setB = new Set(); - setA.add('a'); - setA.add('b'); - setA.add('c'); - setB.add('c'); - setB.add('d'); - var differenceSetAB = setA.difference(setB); - return ( - differenceSetAB.size() === 2 && - DeepEqual(differenceSetAB.values(), ['a', 'b']) - ); - })() -); +var setA = new Set(); +var setB = new Set(); +setA.add('a'); +setA.add('b'); +setA.add('c'); +setB.add('c'); +setB.add('d'); +var differenceSetAB = setA.difference(setB); + +assert.equal(differenceSetAB.size(), 2) +assert.deepEqual(differenceSetAB.values(), ['a', 'b']) ``` # --seed-- diff --git a/curriculum/challenges/english/10-coding-interview-prep/data-structures/use-.has-and-.size-on-an-es6-set.md b/curriculum/challenges/english/10-coding-interview-prep/data-structures/use-.has-and-.size-on-an-es6-set.md index 55d4ac67de8..43e809579f3 100644 --- a/curriculum/challenges/english/10-coding-interview-prep/data-structures/use-.has-and-.size-on-an-es6-set.md +++ b/curriculum/challenges/english/10-coding-interview-prep/data-structures/use-.has-and-.size-on-an-es6-set.md @@ -37,12 +37,8 @@ In this exercise we will pass an array and a value to the checkSet() function. Y `checkSet([4, 5, 6], 3)` should return [ false, 3 ] ```js -assert( - (function () { - var test = checkSet([4, 5, 6], 3); - return DeepEqual(test, [false, 3]); - })() -); +var test = checkSet([4, 5, 6], 3); +assert.deepEqual(test, [false, 3]); ``` # --seed-- diff --git a/curriculum/challenges/english/10-coding-interview-prep/data-structures/use-spread-and-notes-for-es5-set-integration.md b/curriculum/challenges/english/10-coding-interview-prep/data-structures/use-spread-and-notes-for-es5-set-integration.md index 79ba7313b8c..dc208020f6b 100644 --- a/curriculum/challenges/english/10-coding-interview-prep/data-structures/use-spread-and-notes-for-es5-set-integration.md +++ b/curriculum/challenges/english/10-coding-interview-prep/data-structures/use-spread-and-notes-for-es5-set-integration.md @@ -31,12 +31,8 @@ Now you've successfully learned how to use the ES6 `Set()` object, good job! `checkSet(new Set([1,2,3,4,5,6,7])` should return `[1, 2, 3, 4, 5, 6, 7]`. ```js -assert( - (function () { - var test = checkSet(new Set([1, 2, 3, 4, 5, 6, 7])); - return DeepEqual(test, [1, 2, 3, 4, 5, 6, 7]); - })() -); +var test = checkSet(new Set([1, 2, 3, 4, 5, 6, 7])); +assert.deepEqual(test, [1, 2, 3, 4, 5, 6, 7]); ``` # --seed-- diff --git a/tools/client-plugins/browser-scripts/frame-runner.ts b/tools/client-plugins/browser-scripts/frame-runner.ts index fe00477c153..35fb91da292 100644 --- a/tools/client-plugins/browser-scripts/frame-runner.ts +++ b/tools/client-plugins/browser-scripts/frame-runner.ts @@ -27,10 +27,6 @@ async function initTestFrame(e: InitTestFrameArg = { code: {} }) { }; /* eslint-disable @typescript-eslint/no-unused-vars */ - // Fake Deep Equal dependency - const DeepEqual = (a: Record, b: Record) => - JSON.stringify(a) === JSON.stringify(b); - // Hardcode Deep Freeze dependency const DeepFreeze = (o: Record) => { Object.freeze(o); diff --git a/tools/client-plugins/browser-scripts/test-evaluator.ts b/tools/client-plugins/browser-scripts/test-evaluator.ts index cb16b361de9..2add253f530 100644 --- a/tools/client-plugins/browser-scripts/test-evaluator.ts +++ b/tools/client-plugins/browser-scripts/test-evaluator.ts @@ -80,11 +80,6 @@ const __utils = (() => { }; })(); -// Fake Deep Equal dependency -// eslint-disable-next-line @typescript-eslint/no-unused-vars -const DeepEqual = (a: unknown, b: unknown) => - JSON.stringify(a) === JSON.stringify(b); - // We can't simply import these because of how webpack names them when building // the bundle. Since both assert and __helpers have to exist in the global // scope, we have to declare them.