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)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay