diff --git a/submissions/supert111/a-tiny-JS-world/index.js b/submissions/supert111/a-tiny-JS-world/index.js new file mode 100644 index 0000000000..c3d86f2728 --- /dev/null +++ b/submissions/supert111/a-tiny-JS-world/index.js @@ -0,0 +1,58 @@ +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: _put repo URL here_ + Web app: _put project's github pages URL here_ + */ +// ======== OBJECTS DEFINITIONS ======== +// Define your objects here + +const InhabitantsOfTheWorld = function (species, name, gender, legs, hands, saying) { + this.species = species; + this.name = name; + this.gender = gender; + this.legs = legs; + this.hands = hands; + this.saying = saying; + this.friends = []; +} + +const dog = new InhabitantsOfTheWorld('dog', 'Caesar', 'male', 4, 0, 'woof-woof!'); +const cat= new InhabitantsOfTheWorld('cat', 'Musya', 'female', 4, 0, 'meow-meow!'); +const man = new InhabitantsOfTheWorld('human', 'Myk', 'male', 2, 2, 'hello bro!'); +const woman = new InhabitantsOfTheWorld('human', 'Magda', 'female', 2, 2, "I'll kill you!"); + +dog.friends = [cat.name, man.name, woman.name]; +cat.friends = [dog.name, man.name, woman.name]; +man.friends = [dog.name, cat.name, woman.name]; +woman.friends = [dog.name, cat.name, man.name]; + +// ======== 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. + */ + + const inhabitants = [dog, cat, man, woman]; + inhabitants.map(({species, name, gender, legs, hands, saying, friends}) => + print(`species: ${species}; + name: ${name}; + gender: ${gender}; + legs: ${legs}; + hands: ${hands}; + saying: ${saying}; + friends: ${friends};`)); + +/* 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'); + */