I have a variable
var fruits = "Banana, Orange, Apple, Mango";
What I need is that every one that finds a "," skip the line with a "\ n" and good disappears the "," so it looks like this:
Banana
Orange
Apple
Mango
I have a variable
var fruits = "Banana, Orange, Apple, Mango";
What I need is that every one that finds a "," skip the line with a "\ n" and good disappears the "," so it looks like this:
Banana
Orange
Apple
Mango
We replace the spaces in the string and then we separate it by the commas
var array_fruits = fruits.replace(/ /g, '').split(',')
Then we iterate the array in which we have converted the string
for(var i = 0; i < array_fruits.length; i++){
console.log(array_fruits[i])
}
Result:
Banana
Orange
Apple
Mango