Using split and join in JavaScript