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

1 Answer

0 votes
str = "#javascript#"; 
     
if (str[0] === '#' && str[str.length - 1] === '#')
    document.write("yes");
else
    document.write("no");



/*
run:

yes 

*/

 



answered Apr 18, 2019 by avibootz

Related questions

...