+ 1

How can I join every two items in an array?

I am trying to join every two characters in an array of names but not sure how to implement this in js Here is my array: [ 'Jerry', 'Underwood', 'Bob', 'Sheldon', 'Jason', 'Mendoza', 'Alex', 'Jackson', 'Peter', 'Makah', 'Suzie', 'Alisson', 'John', 'Winger', 'Pete', 'McFall', 'Alexis', 'Caper', 'Mason', 'Jacobson', 'Manager1', 'Manager', 'Employee', 'Emp' ] I want it to look like this: [ 'Jerry Underwood', 'Bob Sheldon', 'Jason Mendoza', 'Alex Jackson', etc ] Does anyone know how I can implement this?

19th Jan 2021, 5:51 PM
Austin Cuddeback
Austin Cuddeback - avatar
1 ответ
+ 2
Use for(let a =0;a<arr.length-1;a+=2){ newArr.push(`${arr[a]} ${arr[a+1]}`); }
19th Jan 2021, 6:11 PM
george
george - avatar