Aim of the puzzle: Use the .join()
array method to combine an array of strings into a single string.
Walk through of solution: The .join()
array method is used to join the elements of an array into a single string. If given a string as an argument, it will insert that string in between each element as it joins them. If no argument is given, it will insert a comma. To join an array without anything in-between the elements, an empty string can be used.
In this puzzle, the pieces
array contains 5 separate strings. On the next line, the .join()
method is called on pieces
, and given an empty string as an argument. The resulting string 'SaturdayNight'
is saved to the word
variable.
Sample code solution:
let pieces = ['S','a','tur','day','Night'];
let word = pieces.join('');
console.log(word);
Javascript Concepts: Arrays, Strings, Array Methods, .join()
, Variable Declarations with Let, console.log