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

javascript-javascript1-week3/juan #107

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

PAINj9
Copy link
Collaborator

@PAINj9 PAINj9 commented Nov 28, 2024

No description provided.

Copy link

@yousseftopaji yousseftopaji left a comment

Choose a reason for hiding this comment

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

Great job!
this is a very good implementation, however there is only one mistake, that needs to be fixed.
All the best!


if (names.includes(nameToRemove)) {

names.splice(borrar, borrar);

Choose a reason for hiding this comment

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

Splice(param1, param2) removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements.
@param1 — The zero-based location in the array from which to start removing elements.
@Param2 — The number of elements to remove.

so if the name is "Yana"for example, the first and the second parameter in your code will be 2, and therefore you will get "Yana" and "kristina" removed

does is make sense?


}


Choose a reason for hiding this comment

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

How ever if you want it to be fancy and return the same result, instead of if statement:

Suggested change
function nameToRemove(name) {
names.splice(names.indexOf(name), 1);
}

And you can also try this
it might be fun ;)

Suggested change
function nameToRemove(name) {
names.splice(names.indexOf(name), 1, "Simon");
}

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.

2 participants