I have an array and I want to convert that array into a csv file here is my code and how i store my arrays :
const words = ['item1','item2','item3']
const txtNumber = 2;
let newArr = []
for(let t= 1 ; t <= txtNumber ; t++) {
const data = "item1 , item2 , item3 ,item4";
const findWord = (word) => data.split(",").filter(x => x.includes(word))
const array = [];
for(let i = 0; i < words.length ; i++) {
const x = findWord(words[i]);
array.push(x[0])
}
newArr = array.map(x => x === undefined ? '' : x.trim());
console.log(newArr)
}
how can i store newArr values into items.csv into my pc ?
newArr.push()instead ofnewArr =(as you are over-writing the previous results.)newArr, if each line is added to the CSV inside theforloop this is not an issue. If you could give provide an example of the output you desire it would make it easier.