The aim of this puzzle: Combine the items in the saleItems
array into a single string.
Walkthrough of the solution: The starter code already attaches the elements together using .join()
. The argument is 'GLUE'
is being inserted between each string. You can change that string to something else, like ' & '
to match the solution.
The .join()
method returns a new string, and it won’t affect the original array.
Sample code solution:
(Tap below to reveal)
let saleItems = ['Bug Bites', 'String Beans', 'Console Lager'];
console.log('For sale: ' + saleItems.join(' & '));
JavaScript Concepts: Binary Expression (+ concatenation), console.log()
, .join()