DEV Community

Discussion on: Array.forEach() - for looping through items in an array

Collapse
 
frankwisniewski profile image
Frank Wisniewski

Basically your example is OK.

Exactly this project can be represented in one line...

console.log(
    `I bought ${new Intl.ListFormat("en-GB").format
    (["apple", "banana", "cashew", "pawpaw"])}.`
    )
// I bought apple, banana, cashew and pawpaw.
Enter fullscreen mode Exit fullscreen mode