const sumFactorials = (maxN) => {
let factorial = 1;
const getNextFactorial = (n) => {
factorial *= n;
return factorial;
}
const adder = (sum, n) =>
n < maxN ?
1 / getNextFactorial(n) + adder(sum, n + 1) :
sum + 1 / getNextFactorial(n);
return adder(0, 1);
}
return sumFactorials(3);
const sumG = (n, g) => {
let sum = 0;
let lastNum = 1;
let str = '';
for (let i = 0; i < n; i++) {
sum += lastNum;
str += `${lastNum} `;
lastNum *= g;
}
str = str.slice(0, -1);
console.log(str);
return sum;
};
console.log(sumG(5,2));
If(b1 > 1) {
let sumG = SumG(5,2)
let sum = "";
let sumG = function (n,g) {
const obj = { a: 1 };
const expectedObj = { a: 2 };
someFunction(obj);
expect(obj).toEqual(expectedObj);
someFunction(JSON.parse(JSON.stringify(obj)))
for (let el = 0; el < moscowCity.length; el++) {
if (secondCity === moscowCity[el].city) {
secondMoscowOrNot = "moscow-city"
} else if (secondCity != moscowCity[el].city) {
secondMoscowOrNot = "not-moscow-city"
}
}
for (let le = 0; le < moscowCity.length; le++) {
if (firstCity === moscowCity[le].city) {
firstMoscowOrNot = "moscow-city"
} else if (firstCity != moscowCity[le].city) {
firstMoscowOrNot = "not-moscow-city"
}
}
const isFirstMoscowCity = moscowCity.some((c) => firstCity === c.city);
const isSecondMoscowCity = moscowCity.some((c) => secondCity === c.city);
const arr = [1, 2, 23, 23, 23, 0, 4, 2, 11, 4, 3, 3, 3, 3, 23, 23]
while(i < arrSort.length-1)
let arrSort = arr.sort((a,b)=> a < b ? -1 : 1)
arr.sort((a, b) => a - b)
let numberNext = 1; let i = 0;
while(i < arrSort.length)
;
let numberNext = 0;
let number = arr[0];
for(let i = 1; i < arr.length; i++) {
if(arr[i] === arr[numberNext]) {
number = arr[numberNext];
continue;
}
numberNext++;
}
numberNext+=1 i++
;
?) (() => {
const fields = [
{
name: 'Car',
options: {
min: 'Audi',
max: 'Big Toyota',
}
},
{
name: 'name',
options: {
min: 'Иван',
max: 'Алексей Иванович',
}
}
];
const origStr = 'Привет, меня зовут {{name}}! У меня есть машина {{car}}';
const replaceKeysToText = (str, optionsKey) =>
str.replace(/\{\{\s*(\w+)\s*\}\}/g, (fullMatch, key) => {
const field = fields.find((f) => f.name.toLowerCase() === key);
if(!field) {
return fullMatch;
}
return field.options[optionsKey];
});
const short = replaceKeysToText(origStr, 'min');
const long = replaceKeysToText(origStr, 'max');
return [short, long];
})()
button.onclick = function () {
if (nameEntered) {
if (+input.value === randomNumber) {
text.textContent = "Вы победили!";
button.hidden = true;
return;
}
text.textContent =
+input.value > randomNumber ?
"Неправильно! Моё число меньше!" :
"Неправильно! Моё число больше!";
return;
}
if (!input.value.trim()) {
text.textContent = "Вы не ввели имя!";
return;
}
nameEntered = true;
nameText.textContent = `Здравствуйте, ${input.value}!`;
text.textContent = "Теперь введите число!";
}
const params = taskIds.map((taskId) => ({
method: 'tasks.task.get',
params: {
taskId,
select: ['ID', 'TITLE', 'UF_CRM_TASK']
}
}))
dayOfTheMonth.forEach((date) => {
const day = daysOfTheWeek[(date - 1) % 7];
console.log(`${date} января, ${day}`);
});
Я хочу, чтобы после этого значения выводился символ "%", но с меньшим font-siz'ом. Как бы это реализовать?
ctx.font = 'bold 24px sans-serif';