-
-
Notifications
You must be signed in to change notification settings - Fork 183
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
A Tiny JS World #71
A Tiny JS World #71
Conversation
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.
Good job!
A couple of fixes and we are done.
} | ||
|
||
const inhabitants = [cat, dog, woman, man] | ||
const inhabitantsInformation = inhabitants.map(({name, gender, legs, hands,saying}) => [`${name}; ${gender}; ${legs}; ${hands}; ${saying}`]) |
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.
Having props explicitly listed ({name, gender, legs, hands,saying}
) is a good approach.
Please use #Array.map
and #Array.join
to build the presentation string in the callback function. Remember, you can pack arguments into an array, e.g. ({a1, a2}) => [a1, a2]......some array processing code....
Also why do you need to wrap every presentation string into an array? You have nested arrays as a result.
On your demo page, open dev console and type inhabitantsInformation
to see the data structure.
Feel free seeking help in students' chat.
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.
Please use
#Array.map
and#Array.join
to build the presentation string in the callback function. Remember, you can pack arguments into an array, e.g.({a1, a2}) => [a1, a2]......some array processing code....
я не зовсім розумію що я маю тут зробити : Please use #Array.map and #Array.join to build the presentation string in the callback function. Remember, you can pack arguments into an array, e.g. ({a1, a2}) => [a1, a2]......some array processing code....
як будете мати час напишіть будь-ласка https://t.me/olstaniev
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.
Let's start with answering questions.
Also why do you need to wrap every presentation string into an array? You have nested arrays as a result.
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.
Let's start with answering questions.
Also why do you need to wrap every presentation string into an array? You have nested arrays as a result.
я вже виправив це
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.
метод map повертає мені массив строк
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.
метод map повертає мені массив строк
That's how it works. You can glue them with e.g. .join
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 am a peer developer on this project, and was asked to add 100 more objects with yet another 20 properties.
Please make my life easier.
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.
Please make properties separated exactly with '; '
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.
@OlStani this works, grats.
I guess your latest change was inspired by other soultions. However, your own initial approach might have been improved with a minor change reducing code repetition. E.g.
const inhabitantsInformation = inhabitants.map(({name, gender, legs, hands,saying}) => [name, gender, legs, hands, saying].join('; '))
то було занадто просто, тому не прийшло мені в глову) |
###A Tiny JS World
Demo |
Code base
The code is submitted in a dedicated feature branch.
Only code files are submitted.
Please, review.