How to get first N characters of a string in TypeScript

1 Answer

0 votes
const s = "typescript";
  
const N = 4;
     
const firstN = s.slice(0, N)
     
console.log(firstN);
     
     
   
       
         
/*
run:
         
"type" 
         
*/
  

 



answered Jul 11, 2022 by avibootz
...