Ver originalfunction nl2br(str) { return str.replace(/\n/g,"<br>"); } document.write(nl2br("hola a \n todos"));