You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
Hi Abdullah,
Strings: Please use
let
andconst
instead ofvar
. What doesnewRE
mean? Can you think of a better name? What about something likereadableString
?Arrays:
turtle
so I would expect to findturtle
in the array, notMauro's
.indexOf
method returns the index (>= 0) of the item you are looking for or -1 if the item is not found. In yourif
statement you are using as conditioni
:What if
meerkat
was found at position 0 (whenmeerkat
was the first element in the array). Then, in your code, thesplice
was not done because 0 is 'falsy'. The correct way to do it is:Apart from that everything is in working order.
The text was updated successfully, but these errors were encountered: