Answers for "remove comma from array js"

4

remove commas from string javascript

var stringWithCommas = 'a,b,c,d';
var stringWithoutCommas = stringWithCommas.replace(/,/g, '');
console.log(stringWithoutCommas);
Posted by: Guest on May-17-2020
1

replace comma by new line in js

let availableData = "Hello, Hi, Wassup";
let desiredData = replaceCommaLine(availableData);
function replaceCommaLine(data) {
    //convert string to array and remove whitespace
    let dataToArray = data.split(',').map(item => item.trim());
    //convert array to string replacing comma with new line
    return dataToArray.join("\n");
}
console.log(desiredData);
Posted by: Guest on April-28-2020

Code answers related to "remove comma from array js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language