diff --git a/submissions/SergeyShytikov/tiny-js-world-task/index.js b/submissions/SergeyShytikov/tiny-js-world-task/index.js new file mode 100644 index 0000000000..da2fee2aa9 --- /dev/null +++ b/submissions/SergeyShytikov/tiny-js-world-task/index.js @@ -0,0 +1,76 @@ +/* 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/SergeyShytikov/a-tiny-JS-world + Web app: https://sergeyshytikov.github.io/a-tiny-JS-world/ + */ + +// ======== OBJECTS DEFINITIONS ======== +// Define your objects here +const dog = { + species: 'dog', + name: 'Ice', + // gender: 'male', + legs: 4, + hands: 0, + saying: 'woof-woof!', + gender: 'male', +}; +const cat = { + species: 'cat', + name: 'Cloud', + gender: 'male', + legs: 4, + hands: 0, + saying: 'hsssshhhhh' +}; +const woman = { + species: 'human', + name: 'Sara', + gender: 'female', + legs: 2, + hands: 2, + saying: 'Hi all!' +}; +const man = { + species: 'human', + name: 'David', + gender: 'male', + legs: 2, + hands: 2, + saying: 'Hello everyone!' +}; +const catWoman = { + species: 'human', + name: 'Kitty', + gender: 'female', + legs: 2, + hands: 2, + saying: cat.saying +} +const inhabitants = [dog, cat, man, woman, catWoman]; +const keysOrder = ['species', 'name', 'gender', 'legs', 'hands', 'saying']; + +// ======== OUTPUT ======== +/* Use print(message) for output. + Default tag for message is
. 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('ABC');
+   print('ABC', 'div');
+
+   print('human; John; male; 2; 2; Hello world!; Rex, Tom, Jenny');
+   print('human; John; male; 2; 2; Hello world!; Rex, Tom, Jenny');
+   print('human; John; male; 2; 2; Hello world!; Rex, Tom, Jenny', 'div');
+   */
+
+   inhabitants
+   .map(inhabitant => keysOrder
+      .map(key => inhabitant[key]))
+   .forEach(arrayOfValues => print(arrayOfValues.join('; ')));