(1.) Which of the following are valid arrays (Answer all that apply)
const A = ["Harder", "Better", "Faster", "Stronger"];
const B = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89];
const C = [
"Urban Chestnut",
2009,
"4Hands",
2011,
"Rockwell",
2018
];
const D = [false, 0, "F", true, 1, "T"];
(1-BONUS.) This a valid Array? true / false
const E = [
true,
"HINT: arrays can contain any data type.",
undefined,
function () { alert("Hello World"); },
null,
{ name: "Porky Pig", phrase: "That's All Folks!" },
];
(2.) What is the value of directions
when it is logged?
const directions = ["North", "East", "South", "West"];
directions.pop();
directions.shift();
directions.push("Left");
directions.unshift("Up");
console.log(directions);
(3.) What is the value of allTraits
when it is logged?
(3-B.) What is the value of characterTraits
when it is logged?
(3-C.) Why are these the same OR Why are these different?
const characterTraits = [
"Trustworthy",
"Loyal",
"Helpful",
"Friendly",
"Courteous"
];
const betterTraits = [
"honest and fair",
"friendly and helpful",
"considerate and caring",
"courageous and strong"
];
const allTraits = characterTraits.concat(betterTraits);
console.log(characterTraits, allTraits);
(4.) Fill in the blanks to make the code work:
const pets = [
'Dog',
'Cat',
'Bear',
'Bearded Dragon',
'Frilled Dragon',
'Komodo Dragon',
'Bunny',
'Bird'
];
const dragons = pets.slice( _____ , _____ );
console.log(dragons);
// dragons should return ['Bearded Dragon', 'Frilled Dragon', 'Komodo Dragon']
(4-B.) Log the name of your favorite pet by accessing it from the array
const pets = [
'Dog',
'Cat',
'Bear',
'Bearded Dragon',
'Frilled Dragon',
'Komodo Dragon',
'Bunny',
'Bird'
];
console.log(`My favorite pet is a ${ _____ }`);
(5.) What are the logged values?
const characters = [" ", "A", "B", "C", "D", "E", "F", "G"];
const BIndex = characters.indexOf("B");
const FIndex = characters.indexOf("F");
const hasPercentSign = characters.includes("%");
const mysteryValue = characters.push("H");
console.log(BIndex, FIndex, hasPercentSign, mysteryValue);