0

I want to get a String value of multi-dimensional array and push it into a new Array (That'd be an answer!)

For Example :

var dimStr = [ "First-one", ["Double-one", "Double-two", "Double-three", 
["Triple-one", "Triple-two"] ], "First-two" ] ;

And the output should be :

output = ["First-one", "Double-one", "Double-two", "Double-three", "Triple-one", 
    "Triple-two", "First-two" ] ; 

Thank you very much in advance for your kindness.

The output should be a new Array that contains every String value from dimStr

Barmar
  • 741,623
  • 53
  • 500
  • 612

1 Answers1

0

Look at the array method .flat().

output = dimStr.flat(3);
NetByMatt
  • 703
  • 4
  • 13