How to check if a string starts and ends with another string in JavaScript

1 Answer

0 votes
const s = "javascript php c++ javascript";
  
if (s.startsWith("javascript") && s.endsWith("javascript"))
    console.log("yes");
else
    console.log("no");
 



    
/*
run:
     
"yes"
     
*/

 



answered Nov 22, 2019 by avibootz
edited Jun 23, 2021 by avibootz

Related questions

...