push
const pets = ["Cat", "Dog"];
const wishlist = ["Hamster", "Bunny", "Grasshoppler"];
// var total = pets.concat(wishlist);
var applied = pets.push.apply(pets, wishlist);
applied
const input = document.querySelector('#input');
const button = document.querySelector('#button');
const list = document.querySelector('#list');
const pets = [];
button.addEventListener("click", function (evt) {
if (input.value.length > 0) {
pets.push(input.value);
input.value = "";
render();
}
});
function render () {
list.innerHTML = pets.map(x => `<li>${x}</li>`).join('');
}
This Gist was automatically created by Carbide, a free online programming environment.