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 171 views
1 answer 129 views
1 answer 158 views
1 answer 115 views
1 answer 123 views
1 answer 109 views
1 answer 126 views
...