-
-
Notifications
You must be signed in to change notification settings - Fork 179
preoop task #91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
preoop task #91
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
79 changes: 79 additions & 0 deletions
79
submissions/asaMitaka/Building a Tiny JS World (pre-OOP)/index.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| /* 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: 'Aimi', | ||
| gender: 'female', | ||
| legs: 4, | ||
| hands: 0, | ||
| saying: 'meow!' | ||
| } | ||
|
|
||
| const man = { | ||
| species: 'human', | ||
| name: 'Ihor', | ||
| gender: 'male', | ||
| legs: 2, | ||
| hands: 2, | ||
| saying: 'Hi!' | ||
| } | ||
|
|
||
| const woman = { | ||
| species: 'human', | ||
| name: 'Marina', | ||
| gender: 'female', | ||
| legs: 2, | ||
| hands: 2, | ||
| saying: 'Hello!' | ||
| } | ||
|
|
||
| const catWoman = Object.create(cat); | ||
| catWoman.name = 'Cat-Woman'; | ||
| catWoman.species = 'human'; | ||
| catWoman.legs = 2; | ||
| catWoman.hands = 2; | ||
| catWoman.gender = 'female'; | ||
|
|
||
| const inhabitants = [dog, cat, man, woman, catWoman]; | ||
|
|
||
| function aboutObj(obj) { | ||
| return `${obj.saying} I'm a ${obj.species}. My gender is ${obj.gender}. My name is ${obj.name}. I have ${obj.legs} legs, ${obj.hands} hands`; | ||
| } | ||
|
|
||
| inhabitants.forEach(item => print(aboutObj(item))); | ||
| // ======== 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'); | ||
| */ | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By convention, function names should start with a verb. This way we know it does something rather than contains/represents something.