javascript / beginner
Snippet
Joining Array Elements
The join() method creates and returns a new string by concatenating all elements in an array, separated by a specified string.
snippet.js
1
2
3
const parts = ["Node", "is", "fast"];const message = parts.join(" ");console.log(message);
nodejs
Breakdown
1
const message = parts.join(" ");
Combines the array elements using a space as the separator.
2
console.log(message);
Outputs the resulting string 'Node is fast' to the console.