remove comma from array js code example
Example 1: remove commas from string javascript
var stringWithCommas = 'a,b,c,d';
var stringWithoutCommas = stringWithCommas.replace(/,/g, '');
console.log(stringWithoutCommas);
Example 2: replace comma by new line in js
let availableData = "Hello, Hi, Wassup";
let desiredData = replaceCommaLine(availableData);
function replaceCommaLine(data) {
let dataToArray = data.split(',').map(item => item.trim());
return dataToArray.join("\n");
}
console.log(desiredData);