What is the best way to convert:
const a = ["jan,feb,may", "apr,may,sept,oct", "nov,jan,mar", "dec", "oct,feb,jan"]
to
const res = ["jan","feb","may","apr","may","sept","oct","nov","jan","mar","dec","oct","feb","jan"]
PS: in javascript, I tried using array.reduce()
and split method. but that didn't work. here is what I tried
let flat = arr.reduce((arr, item) => [...arr, ...item.split(',')]);