forked from wesbos/es6.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmore-spread-examples.html
40 lines (35 loc) · 1.01 KB
/
more-spread-examples.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Spread Examples</title>
</head>
<body>
<div class="people">
<p>Wes</p>
<p>Kait</p>
<p>Randy</p>
</div>
<script>
const people = Array.from(document.querySelectorAll('.people p'));
const names = people.map((person) => person.textContent );
const deepDish = {
pizzaName: 'Deep Dish',
size: 'Medium',
ingredients: ['Marinara', 'Italian Sausage', 'Dough', 'Cheese']
};
const shoppingList = ['Milk', 'Flour', ...deepDish.ingredients];
// console.log(shoppingList);
const comments = [
{ id: 209384, text: 'I love your dog!' },
{ id: 523423, text: 'Cuuute! 🐐' },
{ id: 632429, text: 'You are so dumb' },
{ id: 192834, text: 'Nice work on this wes!' },
];
const id = 632429;
const commentIndex = comments.findIndex(comment => comment.id === id);
const newComments = [...comments.slice(0,commentIndex), ...comments.slice(commentIndex + 1)];
console.log(newComments);
</script>
</body>
</html>