let array = ["A", "B"];
let variable = "what you want to add";
//Add the variable to the end of the array
array.push(variable);
//===========================
console.log(array);
//output =>
//["A", "B", "what you want to add"]
/*The push() method adds elements to the end of an array, and unshift() adds
elements to the beginning.*/
let twentyThree = 'XXIII';
let romanNumerals = ['XXI', 'XXII'];
romanNumerals.push(twentyThree);
// now equals ['XIX', 'XX', 'XXI', 'XXII', 'XXIII']
romanNumerals.unshift('XIX', 'XX');
// now equals ['XIX', 'XX', 'XXI', 'XXII']
var vegetables = ['Capsicum',' Carrot','Cucumber','Onion'];
vegetables.push('Okra');
//expected output ['Capsicum',' Carrot','Cucumber','Onion','Okra'];
// .push adds a thing at the last of an array
//combine the name with the age from object javascript function challenges
const customerAndAge = (obj) => {
let array = [];
for (let key in obj) {
array.push(`Customer Name :${key} , Age :${obj[key]}`);
} return array;
};
//if you find this answer is useful ,
//upvote ⇑⇑ , so can the others benefit also . @mohammad alshraideh ( ͡~ ͜ʖ ͡°)
//the array comes here
var numbers = [1, 2, 3, 4];
//here you add another number
numbers.push(5);
//or if you want to do it with words
var words = ["one", "two", "three", "four"];
//then you add a word
words.push("five")
//thanks for reading
*The push() method adds elements to the end of an array, and unshift() adds
elements to the beginning.*/
let twentyThree = 'XXIII';
let romanNumerals = ['XXI', 'XXII'];
romanNumerals.push(twentyThree);
// now equals ['XIX', 'XX', 'XXI', 'XXII', 'XXIII']
romanNumerals.unshift('XIX', 'XX');
// now equals ['XIX', 'XX', 'XXI', 'XXII']