Skip to content

Conversation

@bla6bla6bla6bla6-rgb
Copy link

…ораторных 1,2 и на калькулятор

Copy link

@mxwrlld mxwrlld left a comment

Choose a reason for hiding this comment

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

В целом, хорошо!

Приведите в соответствие с БЭМ, как было в резюме и работу можно считать зачтенной

Напоминаю, что согласно БЭМ классы именуются по шаблону имя-блока__имя-элемента_имя-модификатора. Подробнее тут и тут. Сейчас у вас сплошные блоки, элементов нет.

calculator.js Outdated
Comment on lines 159 to 173
if (!errorMessage) {
// Форматируем результат
const formattedResult = parseFloat(result.toFixed(10));
resultElement.textContent = formattedResult;
resultElement.className = 'success';

// Показываем информацию о вычислении
calculationInfo.textContent = `${num1} ${operationSymbol} ${num2} = ${formattedResult}`;

// Добавляем небольшую анимацию к результату
resultElement.style.transform = 'scale(1.1)';
setTimeout(() => {
resultElement.style.transform = 'scale(1)';
}, 300);
}
Copy link

Choose a reason for hiding this comment

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

Лучше выделить в отдельную функцию

Comment on lines 122 to 156
let result;
let operationSymbol = '';
let errorMessage = '';

// Выполняем выбранную операцию
switch(operation) {
case 'add':
result = num1 + num2;
operationSymbol = '+';
break;
case 'subtract':
result = num1 - num2;
operationSymbol = '-';
break;
case 'multiply':
result = num1 * num2;
operationSymbol = '×';
break;
case 'divide':
// Проверка деления на ноль
if (num2 === 0) {
errorMessage = 'Деление на ноль невозможно';
resultElement.textContent = 'Ошибка: Деление на ноль';
resultElement.className = 'error';
calculationInfo.textContent = errorMessage;
highlightInputError(num2Input);
showHintError(hint2, 'Нельзя делить на ноль');
return;
}
result = num1 / num2;
operationSymbol = '÷';
break;
default:
errorMessage = 'Неизвестная операция';
}
Copy link

Choose a reason for hiding this comment

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

Лучше выделить в отдельную функцию.
Также ошибка деления на ноль и неизвестной операции обрабатываются по - разному.
Также ошибка неизвестной операции никогда не отобразится, поскольку для неё if (!errorMessage) всегда false

@mxwrlld
Copy link

mxwrlld commented Dec 19, 2025

Зачтено!

@mxwrlld mxwrlld closed this Dec 19, 2025
@github-actions github-actions bot added Done and removed In progress labels Dec 19, 2025
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.

2 participants