How to remove the last character from a string in JavaScript

2 Answers

0 votes
let s  = 'javascript';

s = s.slice(0, s.length - 1);

console.log(s);



/*
run:

javascrip

*/

 



answered May 21, 2021 by avibootz
0 votes
let s  = 'javascript';

s = s.substring(0, s.length - 1);

console.log(s);



/*
run:

javascrip

*/

 



answered May 21, 2021 by avibootz
...