Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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("
");
}
console.log(desiredData);
 
PREVIOUS NEXT
Tagged: #replace #comma #line #js
ADD COMMENT
Topic
Name
9+8 =