DEV Community

Rishikesh Agrawani
Rishikesh Agrawani

Posted on

Answer: How can I find out if an array contains a certain string?

The use of regular expressions will be more useful in this case.

In Regular expression, ^ is used to match start, $ is to match end & \s is to match whitespace (newline, tab, space etc.).

function getTheExactStrings(myarray, myname) {
    // Write a regular expression as per your need

Top comments (0)