Andres Ballares - #145
Conversation
| */ | ||
| function removeFirst() {} | ||
| function removeFirst (fruits) { | ||
| let fruit = fruits.shift(); |
There was a problem hiding this comment.
we want to avoid reassigning the value of the parameter so use a different variable name because if we need fruits again in the original state it will no longer exist
| function removeFirstandReturnFirst() {} | ||
| function removeFirstandReturnFirst(fruits) { | ||
| let fruit = fruits.shift(); | ||
| return fruit |
There was a problem hiding this comment.
This returns an array with the first element removed but what we want to return is the first element of the array
| */ | ||
| function lastElementIndexing() {} | ||
| function lastElementIndexing(array) { | ||
| let arra1 = array.slice(length - 1) |
There was a problem hiding this comment.
The instructions say without altering or mutating the array. slice mutates the array.
We want to key into the last index and return that
| */ | ||
| function firstElementIndexing() {} | ||
| const firstElementIndexing = (array) => { | ||
| let arra1 = array.slice(0, 1) |
There was a problem hiding this comment.
Same as the question above but with the first element
| */ | ||
| function removeLast() {} | ||
| function removeLast(fruits) { | ||
| fruits.pop(fruits); |
There was a problem hiding this comment.
We don't need to put the array inside of the pop method
| */ | ||
| function removeFirst() {} | ||
| function removeFirst (fruits) { | ||
| fruits.shift(fruits); |
There was a problem hiding this comment.
no need to place the fruits array inside of the shift method
| if(array1.length > array2.length){ | ||
| return array1; | ||
| } else if (array1.length === array2.length){ | ||
| return "They are the same size" | ||
| } | ||
| else { | ||
| return array2; | ||
| } |
There was a problem hiding this comment.
Make sure that you format you code using an extension like prettier
No description provided.