How to check whether a string ends with another string in JavaScript

1 Answer

0 votes
var s = "javascript php c++";
 
if (s.endsWith("c++"))
    document.write("yes");
else
    document.write("no");

   
   
/*
run:
    
yes 
    
*/

 



answered Nov 22, 2019 by avibootz

Related questions

3 answers 429 views
1 answer 275 views
1 answer 249 views
3 answers 345 views
1 answer 276 views
...