How to remove everything after specific character in Node.js

1 Answer

0 votes
let str = 'javascript c typescript node.js c++ python';
 
const ch = '+'
 
str = str.slice(0, str.indexOf(ch));
 
console.log(str);
 
   
   
   
   
/*
run:
   
javascript c typescript node.js c
   
*/

 



answered Jun 30, 2022 by avibootz

Related questions

...