This repository was archived by the owner on Jan 3, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy path1-writers.js
More file actions
50 lines (45 loc) · 1.12 KB
/
1-writers.js
File metadata and controls
50 lines (45 loc) · 1.12 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
/* Challenge 1: Famous Writers
Did you know you can also have an array of objects? We've created one for you here. Loop through the array,
and for each object, `console.log()` out the sentence:
"Hi, my name is {firstName} {lastName}. I am {age} years old, and work as a {occupation}."
Here is the array:
*/
let writers = [
{
firstName: "Virginia",
lastName: "Woolf",
occupation: "writer",
age: 59,
alive: false
},
{
firstName: "Zadie",
lastName: "Smith",
occupation: "writer",
age: 41,
alive: true
},
{
firstName: "Jane",
lastName: "Austen",
occupation: "writer",
age: 41,
alive: false
},
{
firstName: "bell",
lastName: "hooks",
occupation: "writer",
age: 64,
alive: true
}
];
/*
If you want an extra challenge, only `console.log()` the writers that are alive.
*/
for(let objs=0; objs<writers.length;objs++){
if(writers[objs].alive===true){
//console.log(writers.)
console.log(`Hi, my name is ${writers[objs].firstName} ${writers[objs].lastName}.I am ${writers[objs].age} years old, and work as a ${writers[objs].occupation }`)
}
}