Answer the question
In order to leave comments, you need to log in
Is this shitcode or JS norm?
If a programmer writes such JS code:
money = 1500;
var strMoney = money.toString();
var endNum = strMoney.substr(strMoney.length - 1); // последняя цифра числа
var preEndNum = strMoney.slice(strMoney.length - 2, -1); // предпоследняя цифра числа
var moneyName = "рублей";
if (endNum == 1 && preEndNum != 1) {
moneyName = "рубль";
} else if (endNum >= 2 && endNum <=4 && preEndNum != 1) {
moneyName = "рубля";
}
Answer the question
In order to leave comments, you need to log in
1. the code is bad, I send it to the code review to rewrite it
2. the undertaking is good, it is necessary to praise (but still make it redo normally)
1. This is the code of a person who did not bother to look for any existing internationalization library, or who got acquainted with Intl 'th for which there are quite sane polyfills .
2. This characterizes him as a person who wants to do "well", but it turns out "as always" due to lack of knowledge and experience.
From an algorithmic point of view and some other points (for example, the constant use of var), it's more shitty code than not, an acceptable average level is 5 \ 10. But it's hard to judge the whole code from this piece - it's too simple.
If in the layout \ TK it was clearly written "rubles", then this characterizes him as a person who is attentive to detail. This is a positive quality.
PS Libraries for declension of numeral nouns are redundant in this case.
1. If this code really covers all variations of combinations, then the code is normal.
2. Depends on whether it was necessary to display it, if the designer did not leave extra space for an additional "lay", then this can spoil the look of the page.
1. Not shitty code (I ran the tests, and everything passes), but I would rewrite to check the remainder of the division, and not to check the digits in the number.
2. Positive, attentive to detail
1. Shit code. Errors are not checked, he does not know arithmetic, he does too much.
2. Positively, because he completed the task as required.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question