Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (1.) Which of the following are valid arrays (Answer all that apply)
- ```javascript
- 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"];
- ```
- <br>
- (1-BONUS.) This a valid Array? true / false
- ```javascript
- const E = [
- true,
- "HINT: arrays can contain any data type.",
- undefined,
- function () { alert("Hello World"); },
- null,
- { name: "Porky Pig", phrase: "That's All Folks!" },
- ];
- ```
- <br>
- (2.) What is the value of `directions` when it is logged?
- ```javascript
- const directions = ["North", "East", "South", "West"];
- directions.pop();
- directions.shift();
- directions.push("Left");
- directions.unshift("Up");
- console.log(directions);
- ```
- <br>
- (3.) What is the value of `allTraits` when it is logged?
- <br>(3-B.) What is the value of `characterTraits` when it is logged?
- <br>(3-C.) Why are these the same OR Why are these different?
- ```javascript
- 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);
- ```
- <br>
- (4.) Fill in the blanks to make the code work:
- ```javascript
- 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']
- ```
- <br>
- (4-B.) Log the name of your favorite pet by accessing it from the array
- ```javascript
- const pets = [
- 'Dog',
- 'Cat',
- 'Bear',
- 'Bearded Dragon',
- 'Frilled Dragon',
- 'Komodo Dragon',
- 'Bunny',
- 'Bird'
- ];
- console.log(`My favorite pet is a ${ _____ }`);
- ```
- <br>
- (5.) What are the logged values?
- ```javascript
- 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);
- ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement