DEV Community

Discussion on: 4 Ways to Remove the Last Character from a String in JavaScript 🚮

Collapse
 
jonrandy profile image
Jon Randy 🎖️ • Edited
const bookName = 'Atomic Habits'
const newBookName = [...bookName].reduce((s,c,i,a)=>a.length-i-1?s+c:s)
Enter fullscreen mode Exit fullscreen mode
Collapse
 
gaelgthomas profile image
Gaël Thomas

It's working like a charm! ✨
However, I find it complex to read to do a simple operation. In my opinion, slice is the most straightforward way to remove the last character from a string in Javascript.