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

1
  • Have you looked at the .flat() function? Commented Jan 31, 2023 at 17:48

1 Answer 1

0

Look at the array method .flat().

output = dimStr.flat(3);
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.