How to get the substring before specific character in TypeScript

1 Answer

0 votes
const str = 'javascript c++ c typescript node.js';

const ch = 't'

const subs = str.substring(0, str.indexOf(ch));

console.log(subs);

  
  
  
  
/*
run:
  
"javascrip" 
  
*/

 



answered Feb 18, 2022 by avibootz
...