- if (event.type = "click")
+ if (event.type === "click")
- if (event.type = "dblclick")
+ if (event.type ==== "dblclick")
if (elemTarget === 'li') {
event.target.textContent += '!'
}
function sortMe (s) {
var arr = s.split('');
arr.sort(function (a, b) {
return a > b; // тут любой ваш алгоритм сортировки
});
return arr.join('');
}
var newStr = sortMe('9876');
console.log(newStr); //6789
<input type="text" id="timer" value="25">
var timer = document.getElementById("timer"),
minuteWork = timer.value;
function asc() {
timer.value = (parseInt(minuteWork) + 1);
}
В чем моя ошибка?
const sum = val =>
val instanceof Object
? Object.values(val).reduce((acc, n) => acc + sum(n), 0)
: typeof val === 'number'
? val
: 0;
console.log(sum(obj));
function sum(val) {
let result = 0;
for (const stack = [ val ]; stack.length;) {
const n = stack.pop();
if (n instanceof Object) {
stack.push(...Object.values(n));
} else if (n === +n) {
result += n;
}
}
return result;
}