DEV Community

Discussion on: JavaScript Coding Challenge #1:Learn Split, Splice and Join.

Collapse
 
giacomocerquone profile image
Giacomo Cerquone • Edited

pure and lighter :)

const output = str.split("").reduce((acc, el, idx) => acc[acc.length - 1] === el ? acc.slice(0, -1) : acc + el, "");