-
-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* A tiny JS world task * Change forEach method on map * Fix bugs * Rename function params
- Loading branch information
Showing
1 changed file
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
const cat = { | ||
species: 'cat', | ||
name: 'Kitty', | ||
gender: 'female', | ||
legs: 4, | ||
hands: 0, | ||
saying: 'meow!', | ||
friends: ["cats don't needs any friends"], | ||
}; | ||
|
||
const catWoman = Object.create(cat); | ||
catWoman.species = 'human'; | ||
catWoman.name = 'Catwoman'; | ||
catWoman.gender = 'female'; | ||
catWoman.legs = 2; | ||
catWoman.hands = 2; | ||
catWoman.friends = [cat.name]; | ||
|
||
const woman = { | ||
species: 'human', | ||
name: 'Selina Kyle', | ||
gender: 'female', | ||
legs: 2, | ||
hands: 2, | ||
saying: 'Hello, Batman. Do you know Catwoman?', | ||
friends: [cat.name, catWoman.name], | ||
}; | ||
|
||
const man = { | ||
species: 'human', | ||
name: 'Bruce Wayne', | ||
gender: 'male', | ||
legs: 2, | ||
hands: 2, | ||
saying: "Hi! I'm Batman", | ||
friends: [catWoman.name, woman.name], | ||
}; | ||
|
||
const dog = { | ||
species: 'dog', | ||
name: 'Spike', | ||
gender: 'male', | ||
legs: 4, | ||
hands: 0, | ||
saying: 'woof-woof!', | ||
friends: [woman.name, man.name], | ||
}; | ||
|
||
const persons = [dog, cat, man, woman, catWoman]; | ||
|
||
const attributes = [ | ||
'species', | ||
'name', | ||
'gender', | ||
'legs', | ||
'hands', | ||
'saying', | ||
'friends', | ||
]; | ||
|
||
function personInfoItems(person) { | ||
return attributes.map((key) => person[key]).join('; ') + '.'; | ||
} | ||
|
||
persons.map((person) => print(personInfoItems(person))); |