-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmoreforofloop.js
More file actions
73 lines (53 loc) · 1.68 KB
/
moreforofloop.js
File metadata and controls
73 lines (53 loc) · 1.68 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
const shoes = ['Nike SB', 'Emerica', 'Supra', 'Vans'];
// console.log(shoes.entries());
// const shoe = shoes.entries();
// console.log(shoe);
// you get array itterater
// makes shoes with .entries() because we turned the array into an itterable with .entries() method
// for (const shoe of shoes.entries()) {
// console.log(shoe);
// }
// access the index and the value but there is a better way
// for (const shoe of shoes.entries()) {
// console.log(shoe[0], shoe[1]);
// }
// use destructuring for this
// for (const [i, shoe] of shoes.entries()) {
// console.log(`${shoe} is the ${i} index`);
// }
// you have the Nike SB and the index that matches it.
for (const [i, shoe] of shoes.entries()) {
console.log(`${shoe} is the ${i} index`);
}
// arguments keyword is not available in arrow functions and this is why arrow functions can not be used
// we want this to sum a series of random numbers of addTotal
function addTotal() {
//console.log([1, 2, 3]);
// arguments is a reserve word or keyword
let total = 0;
for(const num of arguments) {
total += num;
}
console.log(total);
return total
//console.log(arguments);
}
// total of 279
// addTotal(12,23,45,56,78,65);
//logged out each letter in Jason Brewer
const name = 'Jason Brewer';
for(const char of name) {
// console.log(char);
}
// this is DOM nodes and this will pull header tags in html specifically header 5
const header = document.querySelectorAll('h5');
// can add a click event
for(const h of header) {
// h is the DOM nodes or actual elements
// 'click' is click event
h.addEventListener('click', function() {
console.log(this.textContent);
}
//const.log(h);
}
//console.log(header);