Answer the question
In order to leave comments, you need to log in
How to combine two js scripts correctly?
Script that counts the number in the list and displays the number<li>
<ul id="list">
var numberOfLis = document.getElementById('list').children.length;
document.getElementById('result').textContent = numberOfLis;
function pluralizeRus(n, forms) {
return n % 10 == 1 && n % 100 != 11
? forms[0]
: (n % 10 >= 2 && n % 10 <= 4
&& (n % 100 < 10
|| n % 100 >= 20) ? forms[1] : forms[2]);
}
alert('6 Скриншот' + pluralizeRus(6, ['', 'а', 'ов']));
Answer the question
In order to leave comments, you need to log in
function pluralizeRus(n, forms) {
return n % 10 == 1 && n % 100 != 11
? forms[0]
: (n % 10 >= 2 && n % 10 <= 4
&& (n % 100 < 10
|| n % 100 >= 20) ? forms[1] : forms[2]);
}
var numberOfLis = document.getElementById('list').children.length;
document.getElementById('result').textContent = numberOfLis + ' Скриншот' + pluralizeRus(numberOfLis, ['', 'а', 'ов']);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question