Reputation: 53
I have an array like this
["Billboard,Television"]
and I want something like this
["Billboard", "Television"]
Upvotes: 0
Views: 23
Reputation: 10655
few other ways:
let str2 = ["Billboard,Television", "have,an,array,like,this"]
let sol = str2.toString().split(",")
console.log(sol)
let str2 = ["Billboard,Television", "have,an,array,like,this"]
let sol = str2.join(",").split(",")
console.log(sol)
Upvotes: 1
Reputation: 10662
You can use flatMap and split for that:
const bla = ["Billboard,Television"];
const result = bla.flatMap(el => el.split(','));
console.log(result)
Upvotes: 1