Skip to content

Commit

Permalink
A tiny js world (kottans#449)
Browse files Browse the repository at this point in the history
* add index.js

* created an empty string

* fix 'created an empty string'

* changed the method

* correction of comments
  • Loading branch information
vl-shevchenko authored Sep 7, 2022
1 parent aff73ff commit 5caf515
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions submissions/vl-shevchenko/js-world/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/* Refer to https://github.com/OleksiyRudenko/a-tiny-JS-world for the task details
Complete the below for code reviewers' convenience:
Code repository: _put repo URL here_
Web app: _put project's github pages URL here_
*/

// ======== OBJECTS DEFINITIONS ========
// Define your objects here
const dog = {
species: 'dog',
name: 'Toby',
gender: 'male',
legs: 4,
hands: 0,
saying: 'woof-woof!'
};
const cat = {
species: 'cat',
name: 'Zhorik',
gender: 'male',
legs: 4,
hands: 0,
saying: 'moooow!'
};
const woman = {
species: 'woman',
name: 'Kate',
gender: 'female',
legs: 2,
hands: 2,
saying: 'What did you say?'
};
const man = {
species: 'man',
name: 'John',
gender: 'male',
legs: 2,
hands: 2,
saying: 'I am fine.'
};
// ======== OUTPUT ========
/* Use print(message) for output.
Default tag for message is <pre>. Use print(message,'div') to change containing element tag.
Message can contain HTML markup. You may also tweak index.html and/or styles.css.
However, please, REFRAIN from improving visuals at least until your code is reviewed
so code reviewers might focus on a single file that is index.js.
*/

/* Print examples:
print('ABC');
print('<strong>ABC</strong>');
print('<strong>ABC</strong>', 'div');
print('human; John; male; 2; 2; Hello world!; Rex, Tom, Jenny');
print('human; <strong>John</strong>; male; 2; 2; <em>Hello world!</em>; Rex, Tom, Jenny');
print('human; <strong>John</strong>; male; 2; 2; <em>Hello world!</em>; Rex, Tom, Jenny', 'div');
*/
let population = [dog, cat, woman, man];
let properties = ['species', 'name', 'gender', 'legs', 'hands', 'saying'];

population.map((population) => {
print(properties.map((key) => population[key]).join('; '));
});

0 comments on commit 5caf515

Please sign in to comment.