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

Building a Tiny JS World #31

Merged
merged 3 commits into from
Jul 31, 2022
Merged

Conversation

maximmorenko
Copy link
Contributor

Building a Tiny JS World

Demo |
Code base

Copy link

@al0tak al0tak left a comment

Choose a reason for hiding this comment

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

Hi! Nice work, let's make it a little better.

};


const inhabitants = [dog, cat, woman, man,];
Copy link

Choose a reason for hiding this comment

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

There is no reason to leave a trailing coma if a whole array is on the same line.

legs: 2,
hands: 2,
saying: 'bye',
};
Copy link

Choose a reason for hiding this comment

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

I'm going to write this once, but you have to fix indentations in the whole file.

return keys.map(key => el[key]);
});

description.map(el => print(el.join('; ')));
Copy link

Choose a reason for hiding this comment

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

Add an empty line in the end of the file.


const keys = ['species', 'name', 'gender', 'legs', 'hands', 'saying'];

const description = inhabitants.map((el) => {
Copy link

Choose a reason for hiding this comment

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

Maybe there could be a better name for an inhabitant than el. el and key are a little too generic.

1. убрал последние запятые в массивах и объектах
2. переименовал елемент на жителя
3. добавил пустую строку в конце файла
@al0tak
Copy link

al0tak commented Jul 30, 2022

Indentations are still wrong. You should close } on the same level where you open it. And trailing comas in arrays that are placed on several lines is good, why did you remove them?

@maximmorenko
Copy link
Contributor Author

я видимо неправильно понял предыдущее замечание по запятым) спасибо! исправил. А если объект записать в одну строчку, то запятая после последней пары ключ-значение тоже будет лишняя? или это касается только массивов? как здесь например:
const man = {hands: 2, saying: 'bye'};
const man = {
hands: 2,
saying: 'bye',
};
оба объекта верно записаны?

@al0tak
Copy link

al0tak commented Jul 31, 2022

Yes, both objects are writter right. This trailing coma is useful when you need to add something in this list of things. If you don't leave the coma, add something (with a coma of course) and check it in a git diff, you'll see both lines effected, because you added a coma to the existing one. It adds a little confusion. Though, sometimes you should not leave a trailing coma, like, for example, JSON syntax required you to remove trailing comas. You did it right now.

@al0tak al0tak merged commit 687a86d into kottans:main Jul 31, 2022
@maximmorenko maximmorenko deleted the building-a-tiny-js-world branch July 31, 2022 22:20
@OleksiyRudenko
Copy link
Member

@maximmorenko we need to fix the following situation:
image

Please submit a PR that will:

  1. remove the code with incompliant path naming
  2. add the same code with compliant path naming
  3. clearly says it is a correction PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants