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

Strings & Arrays Week 3 #4

Open
remarcmij opened this issue Nov 20, 2017 · 0 comments
Open

Strings & Arrays Week 3 #4

remarcmij opened this issue Nov 20, 2017 · 0 comments

Comments

@remarcmij
Copy link

Hi Abdullah,

Strings: Please use let and const instead of var. What does newRE mean? Can you think of a better name? What about something like readableString?

Arrays:

  • Mauro's favourite animal is a turtle so I would expect to find turtle in the array, not Mauro's.
  • The indexOf method returns the index (>= 0) of the item you are looking for or -1 if the item is not found. In your if statement you are using as condition i:
if (i) {
    favoriteAnimals.splice(i, 1);
}

What if meerkat was found at position 0 (when meerkat was the first element in the array). Then, in your code, the splice was not done because 0 is 'falsy'. The correct way to do it is:

if (i !== -1) {
    favoriteAnimals.splice(i, 1);
}

Apart from that everything is in working order.

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

No branches or pull requests

1 participant