How to check if substring exists in another string with JavaScript

1 Answer

0 votes
const s = "javascript c++ php python"
 
if (s.includes("javascript")) {
    console.log("yes");
}

if (!s.includes("swift")) {
    console.log("no");
}
 
 

 
/*
 
run:
 
yes
no
 
*/

 



answered Oct 12, 2020 by avibootz

Related questions

1 answer 145 views
1 answer 148 views
1 answer 138 views
3 answers 230 views
...