javascript change _ to space 1

javascript change _ to space

var str = 'How are you';
var replaced = str.split(' ').join('_');

Here is what the above code is Doing:
1. We’re using the split() method to split the string into an array of substrings.
2. We’re using the join() method to join the array of substrings into a new string.
3. We’re using the replace() method to replace the spaces with underscores.

Similar Posts