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 162 views
1 answer 121 views
1 answer 153 views
1 answer 108 views
1 answer 115 views
1 answer 102 views
1 answer 119 views
...