-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathscript.js
102 lines (82 loc) · 2.47 KB
/
script.js
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// // If you would like to code along with this lesson, you can do so here. The examples below will be covered in class. You can uncomment them one at a time to see the results in your own console. Feel free to add additional code and take notes as needed.
// A METHODICAL APPROACH:
//The code below is supposed to return the sum of the cubes up to the parameter n. For example, if n=4, the function should return 0^3 + 1^3 + 2^3 + 3^3 + 4^3 = 100. However, the code is broken. Using the methodical approach discussed in the README, write your answers to the questions below.
// function sumCubes(n) {
// for (let i = 1; i <= n; i++) {
// let sum = 0;
// sum += i ** 3;
// }
// return sum;
// }
// console.log(sumCubes(4));
// 1. What is my error?
// Answer here:
// 2. Where is my error?
// Answer here:
// 3. What is my code supposed to be doing there?
//
// 4. How do I test my assumptions?
// Answer here:
// 5. What does the test show?
// Answer here:
// // ADDITIONAL CONSOLE METHODS:
// // ERROR EXAMPLE
//console.error('This is my error message');
// // WARN EXAMPLE
//console.warn('This is my warning message.');
// // TABLE EXAMPLE
// const userInfo = {
// userOne: {
// userName: 'esin87',
// password: 'abc123',
// email: '[email protected]'
// },
// userTwo: {
// userName: 'jimmy512',
// password: 'meowsers',
// email: '[email protected]'
// },
// userThree: {
// userName: 'gordoTRON',
// password: 'kibbles4LYFE',
// email: '[email protected]'
// }
// };
//console.log(userInfo);
//console.table(userInfo);
// // TRACE EXAMPLE
// const first = () => {
// second();
// };
// const second = () => {
// third();
// };
// const third = () => {
// fourth();
// };
// const fourth = () => {
// console.trace();
// };
// //remember to call the function to trace it:
// first();
// // STYLIZED EXAMPLE
// console.log(
// '%cThis is my stylish console log.',
// 'background-color: lightgreen; color: red; padding: 5px; border: 1px solid yellow; font-family: Garamond; font-size: 14px;'
// );
// // Debugger
// // Function that returns the sum of even numbers from zero to the parameter passed in (there is a bug in the function as it's written)
//debug this function in Chrome Dev Tools, then VS Code
// let myName = 'Allan';
// let myNumber = 7;
// function evenSum(num) {
// let sum = 0;
// for (let i = 0; i <= num; i += 2) {
// myName = 'Steve';
// sum += i;
// //debugger;
// }
// myName = 'Roger';
// return sum;
// }
// console.log(evenSum(12));