Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Перевая попытка#12

Open
kotoezhik wants to merge 5 commits into
js-improvement:master from
kotoezhik:master
Open

Перевая попытка #12
kotoezhik wants to merge 5 commits into
js-improvement:master from
kotoezhik:master

Conversation

@kotoezhik

@kotoezhik kotoezhik commented Jan 24, 2018

Copy link
Copy Markdown

Перевая попытка. Вопросы по TypeError

Comment thread roman-time.js
*/

function convertHHToRoman(timeHH) {
var timeHHArray = ['', 'X', 'XX', 'XXX', 'XL', 'L'];

@EAndreyF EAndreyF Feb 6, 2018

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Неизменную информацию лучше выносить вне функции, тогда память под переменную не будет повторно выделяться

@EAndreyF EAndreyF Feb 6, 2018

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Сейчас везде поддерживается es6, так что используй только const и let

@kotoezhik kotoezhik Feb 6, 2018

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Вот как раз только сегодня увидел информцию про такие объявления переменных

Comment thread roman-time.js
* @returns {String} – время римскими цифрами (IX:V)
*/

function convertHHToRoman(timeHH) {

@EAndreyF EAndreyF Feb 6, 2018

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Попробуй писать jsDoc к функциям и там же в комментарии назначение функции - в последствии поможет в поддержке кода

Comment thread roman-time.js

function convertHHToRoman(timeHH) {
var timeHHArray = ['', 'X', 'XX', 'XXX', 'XL', 'L'];
timeHH = timeHHArray[timeHH];

@EAndreyF EAndreyF Feb 6, 2018

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Не стоит использовать входные параметры, лучше заведи новую переменную, а ещё лучше сразу сделай return

Comment thread roman-time.js
return timeHH;
}

function convertMMToRoman(timeMM) {

@EAndreyF EAndreyF Feb 6, 2018

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Комментарии аналогичны как и для convertHHToRoman

Comment thread roman-time.js
}

if ((timeHM >= 0) && (timeHM < 10)) {
timeHM = convertMMToRoman(Number(timeHM.charAt(1)));

@EAndreyF EAndreyF Feb 6, 2018

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Если ты хочешь получить просто первый символ, то можешь просто timeHM[0]

Comment thread roman-time.js

checkUndefined(time);

// if (time === undefined) {

@EAndreyF EAndreyF Feb 6, 2018

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Удаляй закомментированный код по окончании работы

Comment thread roman-time.js
// throw new TypeError();
// }

time = time.split(':', 2);

@EAndreyF EAndreyF Feb 6, 2018

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Для каждой операции используй собственную переменную, так легче ориентироваться в коде

Comment thread roman-time.js

time = time.split(':', 2);

for (var i = 0; i < 2; i++) {

@EAndreyF EAndreyF Feb 6, 2018

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Немного странный цикл, внутри ты проверяешь time[0] Попробуй переписать так, чтобы все проверки были в одном месте, так легче их поддерживать, если появится новое условие

Comment thread roman-time.js
return timeHM;
}

var romanTimeHH = convertHHToRoman(Number(timeHM.charAt(0)));

@EAndreyF EAndreyF Feb 6, 2018

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Ты же не часы и минуты конвертируешь, а просто единицы и десятые, так что лучше функции назвать по другому, чтобы они больше отражали, то что ты в них делаешь.

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

Reviewers

@EAndreyF EAndreyF EAndreyF left review comments

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /