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

Модуляция #4

Merged
merged 2 commits into from
Jan 19, 2025

Conversation

JuliaAbramova
Copy link
Contributor

@JuliaAbramova JuliaAbramova commented Jan 16, 2025

@keksobot keksobot changed the title Module5 task1 Модуляция Jan 16, 2025
@@ -0,0 +1,48 @@
import {getRandomNumber} from './getRandomNumber';

const messages = [
Copy link
Collaborator

Choose a reason for hiding this comment

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

Название констант таких называй в верхнем регистре разделяя их нижним подчеркиванием
MESSAGES NAMES PHOTOS_DESCRIPTIONS

function getOneComment(i) {
const oneComment = {};

oneComment.id = getRandomNumber(i * 10 + 1, (i + 1) * 10);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Магические числа, такие как 10, 6, 2 нужно выносить в константы и давать им имя, чтобы было понятно почему именно они, разработчик который в будущем будет смотреть код не будет знать о техническом задании для этой задачи и ему нужно показать так контекст

Copy link
Collaborator

@MaxOrel MaxOrel left a comment

Choose a reason for hiding this comment

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

Принято

export function getComments () {
const comments = [];

const maxComments = getRandomNumber(0,30);
Copy link
Collaborator

Choose a reason for hiding this comment

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

30 тоже магическое число

export function getPhotos() {
const photos = [];

for(let i = 0; i < 25; i++){
Copy link
Collaborator

Choose a reason for hiding this comment

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

25 вынеси в константу

onePhoto.id = i + 1;
onePhoto.url = `photos/${onePhoto.id}.jpg`;
onePhoto.description = photosDescriptions[i];
onePhoto.likes = getRandomNumber(15,200);
Copy link
Collaborator

Choose a reason for hiding this comment

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

15 и 200 в константы

@keksobot keksobot merged commit 69920cc into htmlacademy-javascript:master Jan 19, 2025
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants