8 3 1 common array methods 2f 2f join examples 28 join 29

Solutions on MaxInterview for 8 3 1 common array methods 2f 2f join examples 28 join 29 by the best coders in the world

showing results for - "8 3 1 common array methods 2f 2f join examples 28 join 29"
Violette
17 Apr 2018
1//The general syntax for this method is:
2arrayName.join('connector')
3
4/*join combines all the elements of an array into a string. The 
5connector determines the string that "glues" the array elements 
6together.*/
7
8let arr = [1, 2, 3, 4];
9let words = ['hello', 'world', '!'];
10let newString = '';
11
12newString = arr.join("+");
13console.log(newString);
14
15newString = words.join("");
16console.log(newString);
17
18newString = words.join("_");
19console.log(newString);
20
21//1+2+3+4
22//helloworld!
23//hello_world_!