NiBu NiBu - 3 months ago 8
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
> str = "This is code"
"This is code"
> str.split(' ').map(function(x) {return x.split('').join('+')}).join('_')
"T+h+i+s_i+s_c+o+d+e"