Link to home
Start Free TrialLog in
Avatar of JElster
JElsterFlag for United States of America

asked on

Combine 3 arrays into 1

Hi..
I have 3 arrays

var lastname = ['Smith','Jones'];
var firstname = ['John','Bob'];
var middlename = ['Fred','Tom'];

How can I combine these into 1 array of 'Names'

like  'John Fred Smith' , Bob Tom Jones'

How would you do this using LO-DASH

thanks!
Avatar of Alexandre Simões
Alexandre Simões
Flag of Switzerland image

You can use plain javascript:
var lastname = ['Smith','Jones'];
var firstname = ['John','Bob'];
var middlename = ['Fred','Tom'];

var newArray = lastname.concat(firstname, middlename);

Open in new window

http://www.w3schools.com/jsref/jsref_concat_array.asp
Avatar of JElster

ASKER

I need the new array to look like

 ' John Fred Smith' , ' Bob Tom Jones'    - 2 values
ASKER CERTIFIED SOLUTION
Avatar of Alexandre Simões
Alexandre Simões
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial