Skip to content
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 #593

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update file
  • Loading branch information
SableVector committed Sep 17, 2022
commit 50d3bad3b69771bb2697b91474874d94aeed8a3e
15 changes: 3 additions & 12 deletions submissions/SableVector/tiny-js-world-task/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,8 @@ const inhabitants = {
inhabitants.catwoman.saying = inhabitants.cat.saying;

for (let person in inhabitants) {
const message = getPersonData(inhabitants[person]);
const { name, species, hands, legs, gender, saying } = inhabitants[person];
const message = name + '; ' + species + '; ' + hands + '; ' + legs + '; ' + gender + '; ' + saying + ';';
Copy link
Member

@OleksiyRudenko OleksiyRudenko Sep 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Employ Array methods to reduce code repetition (make code DRY).

What is the difference between for...in and for...of? How can you leverage each?
These aren't rhetorical questions.


print(message, 'h2');
}

function getPersonData(person) {
let str = '';

for (let option in person) {
str += person[option] + '; ';
}

return str;
print(message, 'h3');
}