showing results for - "replace comma by new line in js"
Mike
24 May 2019
1let availableData = "Hello, Hi, Wassup";
2let desiredData = replaceCommaLine(availableData);
3function replaceCommaLine(data) {
4    //convert string to array and remove whitespace
5    let dataToArray = data.split(',').map(item => item.trim());
6    //convert array to string replacing comma with new line
7    return dataToArray.join("\n");
8}
9console.log(desiredData);
queries leading to this page
js replace 22dot with comma 22javascript replace comma with carriage returnjs replace cooma with enter signreplace comma with javascripthow to replace newline with comma in string javascriptreplace comma with newline jshow to replace comma in javascriptreplace comma with line break javascriptjs replace comma with newlinereplace comma with newline htmlreplace comma javascript stringreplace comma with a line break from a string in javascriptreplace all comma with 3cbr 3e c 23replace all commas with new line nodejsjavascript replace commareplace comma from string in javascriptreplace new line with comma in jshow to replace comma with line break in string in angularreplace comma with new line using javascriptmake comma separated items in next line jqueryreplace comma javascriptbutton return value new line instead of commahow to replace comma with new line in jsjquery replace comma with line break create tablejs replace comma with line breakjavascript replace with commareplace with comma in javascriptreplace comma with new line jsreplace all commas and spaces with line break jsremove comma from array jsreplace all comma with 3cbr 3e in c 23replace comma from string javascriptreplace comma in javascripthow to replace comma with new line in javascriptstring replace comma javascriptreplace comma with newline javascriptreplace new line with comma jsjavascript replace comma with line breakreplace comma by new line in jshow to add line break after comma javascriptreplace comma with new line in string javascripthow to replace comma from a string in jsjavascript replace comma with new linereplace comma character with new line javascriptreplace comma with brreplace newline with comma javascriptreplace comma new line string javascript not workingreplace comma with new line javascriptreplace comma with new line typescriptjavascript replace all commas with new linereplace comma in string javascriptreplace new line with comma javascriptreplace dot with comma jsreplace comma by new line in js