-1

let's see I have an array like let filterData= [[1,2,3],[x,y],[z,10]] Have to make it in single line or in single array as an output: this.filterData= [ 1,2,3,x,y,z,10];how can I achieve this in Javascript or typescript language.

anyone have a solution of it..please suggest

`if (this.data && this.data.length > 0) {
     this.filteredData.push(this.data[index].value);
     this.filteredData.push(this.filteredData);
     console.log(this.filteredData)
   }`

2 Answers2

2

Just using Array.flat() can do it

let filterData= [[1,2,3],['x','y'],['z',10]]
filterData = filterData.flat()
console.log(filterData)
flyingfox
  • 13,414
  • 3
  • 24
  • 39
0

Try like this

let filterData= [[1,2,3],["x","y"],["z",10]];
let array=[];
filterData.map((x)=>{x.forEach((m)=>{array.push(m)});})
console.log(array);
Gowtham
  • 61
  • 4