-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
86 lines (65 loc) · 2.3 KB
/
index.html
File metadata and controls
86 lines (65 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<!DOCTYPE html>
<html>
<body>
<h1>Arrow Functions and the This Keyword</h1>
<script>
/*
PROBLEM 1: Change the arrow function on the multiply method to the correct syntax used within an object. Console.log the object before and after the change to see the results printed to the console.
const obj = {
multiplier: 10,
multiply: (a, b) => a * b * this.multiplier;
};
*/
//ENTER YOUR CODE HERE
/*
PROBLEM 2: Change the arrow function called calculateTotal to work within the flock object below while also using the 'this' keyword. Console.log the calculateTotal method to see the results printed to the console.
let sum = 0;
const calculateTotal = (number) => sum += number;
const flock = {
herd: 200,
species: 'seagull'
}
*/
//ENTER YOUR CODE HERE
/*
PROBLEM 3: Change the arrow function called countdown to work within the game object below while using the 'this' keyword. Console.log the method to see the results printed to the console.
const countDown = (num) => {
if (num >= 0) {
console.log(`Current countdown number: ${num}`);
countDown(num - 1);
}
};
const game = {
name: 'Hide n Seek',
players: 5,
location: 'Central Park'
}
*/
//ENTER YOUR CODE HERE
/*
PROBLEM 4: Change the arrow functions called add, subtract, and multiply to work within the tech object below while using the 'this' keyword. Console.log the methods to see the results printed to the console.
const add = (num1, num2) => num1 + num2;
const subtract = (num1, num2) => num1 - num2;
const multiply = (num1, num2) => num1 * num2;
const tech = {
name: 'calculator',
type: 'computer',
number1: 4,
number2: 5
}
*/
//ENTER YOUR CODE HERE
/*
PROBLEM 5 (DEBUGGING): This object contains a value property and a double method that multiplies the value by 2. When invoking the double method, you receive the error: 'NaN' (Not a Number). Fix the code below and console.log the double method to see the correct result printed to the console.
*/
// const obj = {
// value: 10,
// double: () => {
// return this.value * 2;
// }
// };
//
// console.log(obj.double()); // Output: NaN
</script>
</body>
</html>