Answers for "javascript adding an array to an array"

187

javascript append to array

var colors=["red","white"];
colors.push("blue");//append 'blue' to colors
Posted by: Guest on July-22-2019
29

append array js

var colors= ["red","blue"];
	colors.push("yellow"); //["red","blue","yellow"]
Posted by: Guest on November-30-2019
6

javascript adding an array to an array

let chocholates = ['Mars', 'BarOne', 'Tex'];
let chips = ['Doritos', 'Lays', 'Simba'];
let sweets = ['JellyTots'];

let snacks = [];
snacks.concat(chocholates);
// snacks will now be ['Mars', 'BarOne', 'Tex']
// Similarly if we left the snacks array empty and used the following
snacks.concat(chocolates, chips, sweets);
//This would return the snacks array with all other arrays combined together
// ['Mars', 'BarOne', 'Tex', 'Doritos', 'Lays', 'Simba', 'JellyTots']
Posted by: Guest on March-04-2020
0

how to add elements into an array in javascript

var languages = ["JavaScript", "PHP", "Python", "SQL"];
console.log(languages);
languages.push("C");
console.log(languages);
Posted by: Guest on June-27-2021

Code answers related to "javascript adding an array to an array"

Code answers related to "Javascript"

Browse Popular Code Answers by Language