Using code I found researching how to insert spaces between the characters of a string (here), I modified the result, but this doesn't insert additional spaces around the space between 'hello' and 'world' — would you please let me know what I'm missing? Also, what does L%2 do? Thanks! It's important that the result output to the browser.
var s = 'hello world';
var L = s.length;
L = (L%2) ? ' ' + s.charAt(L-1) : '';
// what does L%2 do?
var M = s.match(/(.{1})/g) ;
if (M) s = M.join(' ') ;
document.write(s);