-
-
Notifications
You must be signed in to change notification settings - Fork 184
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
New index.js for tiny js task #258
Merged
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
48c3930
New index.js for tiny js task
Levi123 b9bd5ae
work with an array instead of an object, change name of variables and…
Levi123 bd07097
Update index.js
Levi123 a8c281d
Update index.js
Levi123 81127c4
change function
Levi123 0b91e4c
new functions
Levi123 4ee80fd
new change for tiny-js
Levi123 40a8c5d
New function for print
Levi123 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
This file contains 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,81 @@ | ||
/* 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/Levi123/a-tiny-JS-world | ||
Web app: _put project's github pages URL here_ | ||
*/ | ||
|
||
// ======== OBJECTS DEFINITIONS ======== | ||
// Define your objects here | ||
const dog = { | ||
species: 'dog', | ||
name: 'Rich', | ||
gender: 'male', | ||
legs: 4, | ||
hands: 0, | ||
saying: 'Hav-hav!', | ||
friends: ['Bonya'], | ||
} | ||
|
||
const cat = { | ||
species: 'cat', | ||
name: 'Bonya', | ||
gender: 'female', | ||
legs: 4, | ||
hands: 0, | ||
saying: 'Mr-mr-mr', | ||
friends: ['Rich', 'Catwoman'], | ||
} | ||
|
||
const female = { | ||
species: 'human', | ||
name: 'Olya', | ||
gender: 'female', | ||
legs: 4, | ||
hands: 4, | ||
saying: "Glory to Ukraine", | ||
friends: ['Yura', 'Rich'], | ||
} | ||
|
||
const male = { | ||
species: 'human', | ||
name: 'Yura', | ||
gender: 'male', | ||
legs: 4, | ||
hands: 4, | ||
saying: "Glory to Ukraine", | ||
friends: ['Olya', 'Bonya'], | ||
} | ||
|
||
const catwoman = { | ||
species: 'human', | ||
name: 'Catwoman', | ||
gender: 'female', | ||
legs: 4, | ||
hands: 4, | ||
saying: cat.saying, | ||
friends: ['Bonya'] | ||
} | ||
// ======== 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. | ||
*/ | ||
|
||
function printObject(object){ | ||
const prop = []; | ||
for (element in object){ | ||
prop.push(object[element]); | ||
} | ||
let newStr = prop.join('; '); | ||
print(newStr); | ||
} | ||
|
||
printObject(catwoman); | ||
printObject(male); | ||
printObject(female); | ||
printObject(cat); | ||
printObject(dog); |
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.
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.
I don't understand second point of your massage, i can't use (for...in) at all? and why?
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.
Q: I can't use (for...in) at all? and why?
A: As per explanation above "...when a particular order is required as these do not guarantee any particular order of keys/values."
Only arrays guarantee order of elements.
As a peer developer, knowing that in objects order of keys is not important I can define new objects with properties in different order. It would be great if this didn't affect the code.
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.
I try to change my errors.