Skip to content
Advertisement

Split array of strings on first space and make new array grouping by first word

I have the following array:

JavaScript

What I’d like to do is split this array up, separating the brand from the model of phone, so in the end I can build an array that would give me this:

JavaScript

So far, I have the following unfinished code:

JavaScript

But this isn’t working correctly at all.

Advertisement

Answer

Try with –

JavaScript

Output

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement