How to remove the last N characters from a string in TypeScript

1 Answer

0 votes
let s: string = "typescript programming";
 
const N: number = 4;
s = s.slice(0, -N); 
 
console.log(s);
    
 
   
/*
run:
       
"typescript program"
    
*/

 



answered Sep 12, 2024 by avibootz

Related questions

2 answers 275 views
1 answer 204 views
1 answer 198 views
1 answer 214 views
1 answer 250 views
1 answer 200 views
1 answer 220 views
...