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

Модуль 1 #2

Closed
wants to merge 6 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion 1-module/1-task/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
function factorial(n) {
// ваш код...
let f = 1;
if (n == 0){
f = 1;
} else if (n >= 1){
for(let i = 1; i <= n; i++)
{
f = f * i;
}
} else {
f = String('Введите целое числоы');
}

return f;
}






9 changes: 8 additions & 1 deletion 1-module/2-task/index.js
Original file line number Diff line number Diff line change
@@ -10,9 +10,16 @@ function print(text) {
* чтобы функция sayHello работала корректно
*/
function isValid(name) {
// ваш код...
if (!name) {
return false;
} else if (name.length < 4 || name.includes(" ")) {
return false;
} else {
return true;
}
}


function sayHello() {
let userName = prompt('Введите ваше имя');

10 changes: 9 additions & 1 deletion 1-module/3-task/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
function ucFirst(str) {
// ваш код...
if (!str) {
return '';
} else if (str.lenth == 1) {
return str.toUpperCase();
} else {
return str[0].toUpperCase() + str.slice(1);
}
}


2 changes: 1 addition & 1 deletion 1-module/4-task/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
function checkSpam(str) {
// ваш код...
return str.toUpperCase().includes('XXX') || str.toUpperCase().includes('1XBET')
}
7 changes: 6 additions & 1 deletion 1-module/5-task/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
function truncate(str, maxlength) {
// ваш код...
if (str.length <= maxlength) {
return str;
} else {
return str.slice(0, (maxlength - 1)) + "…";
}
}

9 changes: 8 additions & 1 deletion 2-module/1-task/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
function sumSalary(salaries) {
// ваш код...
let sum = 0;
for (let key in salaries){
if (Number.isFinite(salaries[key])){
sum = sum + salaries[key];
}
}
return(sum);

}
7 changes: 6 additions & 1 deletion 2-module/2-task/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
function isEmpty(obj) {
// ваш код...
let counter = 0;
for (let key in obj) {
counter++;
}
return counter == 0;
}

12 changes: 11 additions & 1 deletion 2-module/3-task/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
let calculator = {
// ваш код
read: function (a, b) {
calculator.a = a;
calculator.b = b;
},
sum: function() {
return calculator.a + calculator.b;
},
mul: function() {
return calculator.a * calculator.b;
}
};

// НЕ УДАЛЯТЬ СТРОКУ, НУЖНА ДЛЯ ПРОВЕРКИ
window.calculator = calculator; // делает ваш калькулятор доступным глобально