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

1st task - Анатийчук #2

Merged
merged 7 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
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
11 changes: 10 additions & 1 deletion 1-module/1-task/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
function factorial(n) {
// ваш код...
if (n < 0) {
return undefined;
}
let result = 1;
let i = 2;
while (i <= n) {
result *=i;
i++;
}
return result;
}
15 changes: 12 additions & 3 deletions 1-module/2-task/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,22 @@ function print(text) {
* чтобы функция sayHello работала корректно
*/
function isValid(name) {
// ваш код...
}
if (!name) {
return false;
}
if (name.includes (" ")) {
return false;
}
if (name.length < 4) {
return false;
}
return true;
};// ваш код...

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

if (isValid(userName)) {
if (isValid (userName) ) {
print(`Welcome back, ${userName}!`);
} else {
print('Некорректное имя');
Expand Down
3 changes: 2 additions & 1 deletion 1-module/3-task/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
function ucFirst(str) {
// ваш код...
if (!str) return str;
return str [0].toUpperCase() + str.slice (1);// ваш код...
}
3 changes: 2 additions & 1 deletion 1-module/4-task/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
function checkSpam(str) {
// ваш код...
const lowerStr = str.toLowerCase();
return lowerStr.includes ("1xbet") || lowerStr.includes ("xxx") // ваш код...
}
5 changes: 4 additions & 1 deletion 1-module/5-task/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
function truncate(str, maxlength) {
// ваш код...
if (str. length > maxlength) {
return str. slice (0, maxlength -1) + "…";// ваш код...
}
return str
}
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 total = 0;
for (let key in salaries) {
let value = salaries [key];
if (typeof value === 'number' && isFinite (value) ) {
total +=value;
}
}
return total;// ваш код...
}
5 changes: 4 additions & 1 deletion 2-module/2-task/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
function isEmpty(obj) {
// ваш код...
for (let key in obj) {
return false;
}
return true // ваш код...
}
13 changes: 12 additions & 1 deletion 2-module/3-task/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
let calculator = {
// ваш код
a: 0,
b: 0,
read (a, b) {
this.a = a;
this.b = b;
},
sum () {
return this.a + this.b;
},
mul () {
return this.a * this.b;
}
};

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