let pets = ['Dog', 'Cat', 'Hamster'];
console.log('Before');
console.log(pets);
console.log(`\n----------------------------------------------\n`);
// method 1
const add1 = pets[3] = 'Squirrel'
console.log(`pets[3] returns element: ${add1}`);
console.log('\nAfter');
console.log(pets);
const add2 = pets[5] = 'Hedgehog'
console.log(`\n\npets[5] returns element: ${add2}`);
console.log('\nAfter');
console.log(pets);
console.log(`\n----------------------------------------------\n`);
// method 2
pets = ['Dog', 'Cat', 'Humster'];
const push = pets.push('Betta Fish');
console.log(`returns element: ${push}`);
console.log('\nAfter');
console.log(pets);
This Pen doesn't use any external CSS resources.