NiBu NiBu - 1 year ago 47
Javascript Question

I want to add a "+" between every character in a string and a "_" between every space (javascript)

For example: "This is code" should return "T+h+i+s_i+s_c+o+d+e"

function addStuff(str) {
return str.split("").join("_");

This returns only "This_is_code"

Need help adding the "+"'s

NON REGEX answers please***

Answer Source
> str = "This is code"
"This is code"
> str.split(' ').map(function(x) {return x.split('').join('+')}).join('_')