Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add two more katas for [].fill() from MDN #56

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions katas/es6/language/array-api/fill.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,19 @@ describe('`Array.prototype.fill` can fill up an array with one value', () => {
assert.deepEqual(arr, [1, 42, 3]);
});

it('is a mutating method, and will change this object itself', function() {
const arr = new Array(3);
//// arr.fill('foo')
arr.fill(8);

assert.deepEqual(arr, [8,8,8]);
});

it('when gets passed an object, all elements of the mutated array would be the same reference to that object', function(){
//// const obj = {hi: 'foobar'};
const obj = {hi: 'es6 katas'};
const arr = Array(3).fill(obj);

assert.equal(arr[2].hi, 'es6 katas');
});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the test description and how it is supposed to make the user arrive at the solution.
What I understand from the test description would be the following code (passing test).

const obj = {};
const arr = Array(1).fill(obj);
assert.equal(arr[0], obj);

wouldn't it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you're right 😂

});