const elems = document.querySelectorAll('button');
elems.forEach(el => el.addEventListener('click', function() {
alert(this.textContent);
}));
let num = 123456;
let sum = String(num)
.split('')
.reduce((acc, cur) => acc + Number(cur), 0)
alert(sum);
let num = 123456;
let sum = 0;
let str = String(num);
for (let i = 0; i < str.length; i++) {
sum += Number(str[i]);
}
alert(sum);
.block{
margin-top: 155px;
}
h1{
font-size: 32px;
line-height: 1;
position: relative;
display: inline-block;
}
h1::before{
font-family: Roboto;
display: inline-block;
font-weight: 900;
position: relative;
content: '?';
color: yellow;
font-size: 300px;
line-height: 1;
left: 50%;
top: 0;
transform: translateY(-50%);
z-index: -1;
}
// jQuery
$el.slideUp();
$el.slideDown();
// Нативно
const originHeight = '100px';
el.style.transition = 'height 3s';
// slideUp
el.style.height = '0px';
// slideDown
el.style.height = originHeight;