Skip to content

Commit

Permalink
Merge pull request #3 from KirillDolbnya/master
Browse files Browse the repository at this point in the history
Решил задачи первого модуля
  • Loading branch information
jsru-1 authored Feb 15, 2025
2 parents 117a33d + bc8261a commit a66e03b
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 8 deletions.
12 changes: 11 additions & 1 deletion 1-module/1-task/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
function factorial(n) {
// ваш код...
let result = n;

if (n === 0 || n === 1) {
return 1;
}

for (let i = 1; i < n; i++) {
result *= (n - i);
}

return result;
}
2 changes: 1 addition & 1 deletion 1-module/2-task/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function print(text) {
* чтобы функция sayHello работала корректно
*/
function isValid(name) {
// ваш код...
return Boolean(name) && name.length >= 4 && !name.includes(" ");
}

function sayHello() {
Expand Down
6 changes: 5 additions & 1 deletion 1-module/3-task/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
function ucFirst(str) {
// ваш код...
if (str.length !== 0) {
return str.slice(0, 1).toUpperCase() + str.slice(1);
}

return str;
}
8 changes: 7 additions & 1 deletion 1-module/4-task/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
function checkSpam(str) {
// ваш код...
if (str.length === 0) {
return false;
}

str = str.toLowerCase();

return str.includes('1xbet') || str.includes('xxxxx');
}
6 changes: 5 additions & 1 deletion 1-module/5-task/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
function truncate(str, maxlength) {
// ваш код...
if (str.length <= maxlength) {
return str;
}else{
return str.substring(0, maxlength - 1) + '…';
}
}
10 changes: 9 additions & 1 deletion 2-module/1-task/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
function sumSalary(salaries) {
// ваш код...
let price = 0;

for(let key in salaries) {
if (parseInt(salaries[key])) {
price += salaries[key];
}
}

return price;
}
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) {
// ваш код...
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
return false;
}
}
return true;
}
11 changes: 10 additions & 1 deletion 2-module/3-task/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
let calculator = {
// ваш код
read: function (a, b) {
this.a = a;
this.b = b;
},
sum: function () {
return this.a + this.b;
},
mul: function () {
return this.a * this.b;
}
};

// НЕ УДАЛЯТЬ СТРОКУ, НУЖНА ДЛЯ ПРОВЕРКИ
Expand Down

0 comments on commit a66e03b

Please sign in to comment.