Skip to content

Feedback Strings & Arrays Week 3 #2

@remarcmij

Description

@remarcmij

Hi Yousef,

Strings: Looks goods. Since your regular expression doesn't include letters you don't actually need the i flag. A simple /,/g would have been sufficient.

Arrays: The only comment I have is about your use of indexOf. This method returns the index of the item to search for (>= 0) or -1 if it is not found. It doesn't return a boolean. So I would change your code as follow:

if (indexOfItem === -1) {
  console.log("The item you are looking for doesn't exist");
} else { 
  console.log('The item you are looking for is at index: ' + indexOfItem);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions