-
-
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 * Added a few semicolons * Rewroted main print function using Array#map and Array#forEach methods, rename a few variables * Rewrote main print function using Array#map
- Loading branch information
Showing
1 changed file
with
69 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,69 @@ | ||
/* | ||
Refer to https://github.com/OleksiyRudenko/a-tiny-JS-world for the task details | ||
Complete the below for code reviewers' convenience: | ||
Code repository: https://github.com/franchukv/a-tiny-JS-world | ||
Web app: https://franchukv.github.io/a-tiny-JS-world/ | ||
*/ | ||
|
||
// ======== OBJECTS DEFINITIONS ======== | ||
const man = { | ||
species: 'human', | ||
gender: 'male', | ||
name: 'Drogo', | ||
status: 'Khal', | ||
hands: 2, | ||
feets: 2, | ||
saying: 'Sheikh Ma Shieraki Anni.', | ||
} | ||
|
||
const woman = { | ||
species: 'human', | ||
gender: 'female', | ||
name: 'Daenerys', | ||
status: 'Daenerys of House Targaryen, First with Her Name, Breaker of Chains and Mother of Dragons', | ||
hands: 2, | ||
feets: 2, | ||
saying: 'Drakaris!', | ||
friends: `Fell in love with ${man.name}.`, | ||
} | ||
|
||
const dog = { | ||
species: 'dog', | ||
gender: 'male', | ||
name: 'Sharik', | ||
status: "Yard's terrier", | ||
hands: 0, | ||
feets: 4, | ||
saying: 'woof-woof!', | ||
friends: `Only ${man.name} is friends.`, | ||
} | ||
|
||
const cat = { | ||
species: 'cat', | ||
gender: 'female', | ||
name: 'Bastet', | ||
status: "Pharaoh's cat", | ||
hands: 0, | ||
feets: 4, | ||
saying: 'Meow, bow to me!', | ||
friends: 'No friends, only servants!' | ||
} | ||
|
||
const catwoman = { | ||
species: 'human', | ||
gender: 'female', | ||
name: 'Selina Kyle', | ||
status: "Superhero", | ||
hands: 2, | ||
feets: 2, | ||
saying: cat.saying, | ||
friends: `In astral connection with ${cat.name}.`, | ||
} | ||
|
||
// ======== OUTPUT ======== | ||
const inhabitants = [man, woman, dog, cat, catwoman]; | ||
const properties = ['species', 'gender', 'name', 'status', 'hands', 'feets', 'saying', 'friends']; | ||
|
||
inhabitants.forEach((habitant) => { | ||
print(properties.map((property) => habitant[property]).join('; ')); | ||
}) |