0 day streak
javascript / beginner
Snippet

Adding Elements to an Array with Push

The .push() method is used to add one or more new elements to the very end of an existing array.

snippet.js
javascript
1
2
3
const colors = ["Red", "Green"];
colors.push("Blue");
console.log(colors);
nodejs
Breakdown
1
colors.push("Blue");
Appends the string "Blue" to the colors array.