Search
 
SCRIPT & CODE EXAMPLE
 

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);
Comment

PREVIOUS NEXT
Code Example
Javascript :: get size of json object 
Javascript :: how create an index mongodb 
Javascript :: a href javascript void 
Javascript :: how to delete element at a particular index of array in react js 
Javascript :: javascript ES6 destructure dynamic property name 
Javascript :: sort array of objects javascript by date 
Javascript :: toggle in react 
Javascript :: jquery validation phone number 
Javascript :: sass config.json vs code 
Javascript :: javascript check if time is less than 
Javascript :: axios async get 
Javascript :: cache remove using ajax 
Javascript :: use node js to check if a json file exists 
Javascript :: vue computed composition api 
Javascript :: add access-control-allow-origin in node js 
Javascript :: find duplicates in array javascript 
Javascript :: vue shortcut to create component 
Javascript :: collection to array javascript 
Javascript :: is_int js 
Javascript :: javascript sum array of objects by key 
Javascript :: Uncaught TypeError: console.log is not a function 
Javascript :: insert json file in python 
Javascript :: javascript insert before 
Javascript :: cannot use import statement outside a module in jest 
Javascript :: angular datatable reload with pagination 
Javascript :: axios get error response message 
Javascript :: on hover add class on children jquery 
Javascript :: jquery hasclass 
Javascript :: js input hidden get value 
Javascript :: get nth character of string javascript 
ADD CONTENT
Topic
Content
Source link
Name
9+2 =