How to keep only first N characters in a string with TypeScript

1 Answer

0 votes
let str = 'TypeScrip C++ C PHP';

const N = 6;

str = str.substring(0, N);

console.log(str);
  
  
  
  
/*
run:

"TypeSc" 
  
*/

 



answered May 15, 2022 by avibootz
...