From 3bfa57041dd7fcdc3891e247a7b378459ab01d17 Mon Sep 17 00:00:00 2001 From: brad_Dev <50883158+bsrwilliams@users.noreply.github.com> Date: Tue, 12 Jan 2021 15:57:05 +0000 Subject: [PATCH 1/3] Update flatten-array.js Flattened and sorted array --- test/flatten-array.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/flatten-array.js b/test/flatten-array.js index c7f0632..172ec13 100644 --- a/test/flatten-array.js +++ b/test/flatten-array.js @@ -2,7 +2,10 @@ describe('flatten array', function () { it('should flatten an array', function () { var arr = [1, 2, [1, 2, [3, 4, 5, [1]]], 2, [2]], expected = [1, 1, 1, 2, 2, 2, 2, 3, 4, 5]; + + arr = arr.flat(Infinity) + arr.sort(); expect(arr).toEqual(expected); }); -}); \ No newline at end of file +}); From 754fa2e21f3cd9c4dee518f0269571d744846a65 Mon Sep 17 00:00:00 2001 From: brad_Dev <50883158+bsrwilliams@users.noreply.github.com> Date: Tue, 12 Jan 2021 15:59:32 +0000 Subject: [PATCH 2/3] Update scoping.js Call Module function to set 'bar' to foo before value is returned otherwise will return undefined --- test/scoping.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/scoping.js b/test/scoping.js index 557c54a..2a3d255 100644 --- a/test/scoping.js +++ b/test/scoping.js @@ -12,6 +12,7 @@ describe('scoping', function () { } Module.prototype.method = function() { + Module(); return this.foo; }; @@ -21,4 +22,4 @@ describe('scoping', function () { expect(mod.req()).toBe('bar'); }); -}); \ No newline at end of file +}); From 9032ee946c0ee6d89fe960fce24c5498c99e51fd Mon Sep 17 00:00:00 2001 From: brad_Dev <50883158+bsrwilliams@users.noreply.github.com> Date: Tue, 12 Jan 2021 16:03:36 +0000 Subject: [PATCH 3/3] Update clone-object.js Objects are referenced to memory. This solution uses Object.assign to clone the properties from one object to another. --- test/clone-object.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/clone-object.js b/test/clone-object.js index 86ec647..6aae902 100644 --- a/test/clone-object.js +++ b/test/clone-object.js @@ -2,6 +2,7 @@ describe('clone object', function () { it('should clone an object', function () { var expected = {name: 'Ahmed', age: 27, skills: ['cycling', 'walking', 'eating']}, obj = {}; + obj = Object.assign(obj, expected); expect(obj).toEqual(expected); expect(obj).not.toBe(expected);