Skip to content

Commit

Permalink
Uploaded the A Tiny JS World challenge code (#597)
Browse files Browse the repository at this point in the history
  • Loading branch information
DeamonFire authored Sep 20, 2022
1 parent d929c52 commit 081a32b
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions submissions/DeamonFire/A-Tiny-JS-World/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { print } from './js/lib.js';
/* 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/DeamonFire/a-tiny-JS-world
Web app: https://deamonfire.github.io/a-tiny-JS-world/
*/

// ======== OBJECTS DEFINITIONS ========
const dog = {
species: 'dog',
name: 'Azov',
gender: 'male',
hands: 0,
legs: 4,
say: 'Glory to Ukraine!'
};

const cat = {
species: 'cat' ,
name: 'Izyum',
gender: 'female',
hands: 0,
legs: 4,
say: 'Glory to heroes!'
};

const woman = {
species: 'human',
name: 'Darynka',
gender: 'female',
hands: 2,
legs: 2,
say: 'Glory to the Nation!'
};

const man = {
species: 'human',
name: 'Dmytro',
gender: 'male',
hands: 2,
legs: 2,
say: 'Death to enemies!'
};

const catWoman = {
species: 'catHuman',
name: 'Ania',
gender: 'female',
hands: 2,
legs: 2,
say: cat.say
};

const habitansWorld = [dog, cat, woman, man, catWoman];
const props = ['species', 'name', 'gender', 'hands', 'legs', 'say'];

// ======== OUTPUT ========
const residents = habitansWorld
.map((habitans) => props.map((prop) => habitans[prop]).join("; "))
.join("<br>");
print(residents, "div");

0 comments on commit 081a32b

Please sign in to comment.