Put your answers in the provided answers.txt
let color = 'yellow';
let crimeFighters = {
turtles: ["Leonardo", "Raphael", "Michelangelo", "Donatello"],
rangers: {
red: "Jason",
black: "Zack",
yellow: "Trini",
blue: "Billy",
pink: "Kimberly",
green: "Tommy"
}
};
if (crimeFighters.rangers.red === 'Jason') crimeFighters.rangers.blue = 'Bob';
let b = "cat";
let a = "dog";
a = b;
a === "duck"
const myFunc = function() {
"hello world";
};
console.log(myFunc)
5. The student that wrote the code above expected "hello world" to log in the console. Explain what change(s) are needed to make the code work as expected - without console.log
being added within the myFunc
function?
let stuff = [
['one', 2, false],
{
apples: 12,
fn: function() { return this.apples; }
},
false
];
let a = 2;
1. Declare a variable named turtles
and assign an array containing the strings "Donatello", "Leonardo", "Michelangelo", and "Raphael":
2. Write a forEach
loop to console.log
each name in turtles, appending the string " likes pizza" to each name:
class Turtle {
constructor(name, maskColor) {
// Question 3 answer below
name: "",
maskColor: "";
}
// add the sayName method below (Question 4)
function sayName(name) {
console.log(`I am ${name}`);
}
}
// Create a new Turtle object below (Question 5)
let leo = new Turtle("Leonardo", "Blue");
5. Write the line of code above that uses the Turtle
class above to create a turtle object with a name
of "Leonardo" and a maskColor
of "blue"; and assign the new object to a variable named leo
.
let car = {make: 'Toyota', year: 2017, model: 'Prius'};