Skip to content

Commit

Permalink
A Tiny JS World task (#402)
Browse files Browse the repository at this point in the history
* 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
franchukv authored Sep 7, 2022
1 parent c9b7a58 commit 2049183
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions submissions/franchukv/a-tiny-js-world/index.js
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('; '));
})

0 comments on commit 2049183

Please sign in to comment.