-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from KirillDolbnya/master
Решил задачи первого модуля
- Loading branch information
Showing
8 changed files
with
54 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) + '…'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters