js lec 1 added

This commit is contained in:
2026-01-03 13:40:15 +10:00
parent cca7d57569
commit e6806a2366
18 changed files with 150 additions and 58 deletions

View File

@@ -0,0 +1,2 @@
alert("Hello, world!");
document.write("Hello, world!");

View File

@@ -0,0 +1,6 @@
let _name = "Алина";
let email = "alina@test.ru";
let message = `Доброго времени суток, ${_name}! Мы отправили Вам приглашение на почту ${email}.`;
document.write(`<h3>${message}</h3>`);

View File

@@ -0,0 +1,8 @@
let p = prompt("Введите значение переменной p:");
if (isNaN(parseFloat(p)) || !isFinite(Number(p))) {
alert("Ошибка: введено не число.");
} else {
p = Number(p) + 1;
alert(`Увеличенное значение переменной p: ${p}`);
}

View File

@@ -0,0 +1 @@
let result = n > 0 ? 1 / n : n < 0 ? 1 / n ** 2 : 0;

10
lectures/lec5/p1/task5.js Normal file
View File

@@ -0,0 +1,10 @@
let n = 81;
let i = 1;
let out = "<select>";
for (let i = 1; i ** 2 <= n; i+=2) {
out += `<option>${i**2}</option>`
}
out += "</select>";
document.write(out);

View File

@@ -0,0 +1,3 @@
function sum() {
return arguments.reduce((total, num) => total + num, 0);
}

View File

@@ -0,0 +1,3 @@
sum = function(...args) {
return args.filter(num => num % 2 !== 0).reduce((acc, num) => acc + num, 0);
}

View File

@@ -0,0 +1,3 @@
sum = (...args) => {
return args.filter(num => num % 2 !== 0).reduce((acc, num) => acc + num, 0);
}