Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b476eb5

Browse files
array cardio added more methods
1 parent f4e09b9 commit b476eb5

File tree

1 file changed

+39
-3
lines changed

1 file changed

+39
-3
lines changed

‎each day build day!/Day 4/index.html

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,12 @@
7070
//convert the NodeList to array
7171
//const links = Array.from(categories.querySelectorAll('a'));
7272
//or better 🧑
73-
const links = [...categories.querySelectorAll('a')]; //we need only links returns a NodeList
73+
// const links = [...categories.querySelectorAll('a')]; //we need only links returns a NodeList
7474

75-
const namesWithde = links
75+
/* const namesWithde = links
7676
.map(item => item.contentText)
7777
.filter(name => name.includes('de'));
78-
console.table(namesWithde);
78+
console.table(namesWithde); */
7979
// 7. sort Exercise
8080
// Sort the people alphabetically by last name
8181
const sortedPeople = people.sort((a, b) => {
@@ -101,6 +101,42 @@
101101
console.log('8:', reduced)
102102

103103

104+
const characters = [
105+
{ name: 'Mario', year: 1988 },
106+
{ name: 'Luigi', year: 1986 },
107+
{ name: 'Deadpool', year: 1980 },
108+
{ name: 'Lego', year: 2018 }
109+
];
110+
111+
const comments = [
112+
{ text: 'Love this!', id: 523423 },
113+
{ text: 'Super good', id: 823423 },
114+
{ text: 'You are the best', id: 2039842 },
115+
{ text: 'Ramen is my fav food ever', id: 123523 },
116+
{ text: 'Nice Nice Nice!', id: 542328 }
117+
];
118+
119+
// Some and Every Checks
120+
const isAdult = characters.some(person => ((new Date()).getFullYear()) - person.year >= 19); // is at least one person 19 or older?
121+
const areAdults = characters.every(person=>((new Date().getFullYear)) - person.year <= 19) // is everyone 19 or older?
122+
console.log("some :",isAdult, "every :", areAdults);
123+
// Array.prototype.find()
124+
// Find is like filter, but instead returns just the one you are looking for
125+
// find the comment with the ID of 823423
126+
const comment = comments.find(comment => comment.id === 823423)
127+
console.log("find", comment)
128+
// Array.prototype.findIndex()
129+
// Find the comment with this ID
130+
// delete the comment with the ID of 823423
131+
const index = comments.findIndex(comment => comment.id === 823423)
132+
//comments.splice(index,1)
133+
134+
const newComments = [
135+
...comments.slice(0,index),
136+
...comments.slice(index+1)
137+
];
138+
console.table(newComments);
139+
104140
</script>
105141
</body>
106142

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /