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 4 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
13 changes: 12 additions & 1 deletion 1-module/1-task/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
function factorial(n) {
// ваш код...
if (n < 0) {
return undefined;
}
let result = 1;
let i = 2;
while (i <= n) {
result *=i;
i++;
}
return result;
}

console.log ( factorial (3) );

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Надо из кода убрать все лищнее. Должно остаться только решение задачи

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
4 changes: 3 additions & 1 deletion 1-module/3-task/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
function ucFirst(str) {
// ваш код...
if (!str) return str;
return str [0].toUpperCase() + str.slice (1);// ваш код...
}
alert (ucFirst ("вася"));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Надо из кода убрать все лищнее. Должно остаться только решение задачи

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
}
Loading