Skip to content

Andres Ballares - #145

Open
AndresBallares wants to merge 4 commits into
joinpursuit:masterfrom
AndresBallares:master
Open

Andres Ballares#145
AndresBallares wants to merge 4 commits into
joinpursuit:masterfrom
AndresBallares:master

Conversation

@AndresBallares

Copy link
Copy Markdown

No description provided.

Comment thread problems/arraysIntro.js Outdated
*/
function removeFirst() {}
function removeFirst (fruits) {
let fruit = fruits.shift();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Comment thread problems/arraysIntro.js Outdated
function removeFirstandReturnFirst() {}
function removeFirstandReturnFirst(fruits) {
let fruit = fruits.shift();
return fruit

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This returns an array with the first element removed but what we want to return is the first element of the array

Comment thread problems/arraysIntro.js Outdated
*/
function lastElementIndexing() {}
function lastElementIndexing(array) {
let arra1 = array.slice(length - 1)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The instructions say without altering or mutating the array. slice mutates the array.

We want to key into the last index and return that

Comment thread problems/arraysIntro.js Outdated
*/
function firstElementIndexing() {}
const firstElementIndexing = (array) => {
let arra1 = array.slice(0, 1)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Same as the question above but with the first element

Comment thread problems/arraysIntro.js Outdated
*/
function removeLast() {}
function removeLast(fruits) {
fruits.pop(fruits);

@Sparkadelic177 Sparkadelic177 Jan 13, 2021

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

We don't need to put the array inside of the pop method

Comment thread problems/arraysIntro.js Outdated
*/
function removeFirst() {}
function removeFirst (fruits) {
fruits.shift(fruits);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

no need to place the fruits array inside of the shift method

Comment thread problems/arraysIntro.js Outdated
Comment on lines +96 to +103
if(array1.length > array2.length){
return array1;
} else if (array1.length === array2.length){
return "They are the same size"
}
else {
return array2;
}

@Sparkadelic177 Sparkadelic177 Jan 13, 2021

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Make sure that you format you code using an extension like prettier

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants