var clickId1 = document.getElementById('clickId1') // кнопка
var contentId1 = document.getElementById('contentId1') // контент
const myClass = 'contentClass2'
switch(localStorage.getItem('theme')) {
case myClass:
contentId1.classList.toggle(myClass)
}
clickId1.addEventListener('click', () => {
contentId1.classList.toggle(myClass)
if (contentId1.classList.contains(myClass)) {
localStorage.setItem('theme', myClass);
} else {
localStorage.removeItem('theme', myClass);
}
})
const admins = data
.filter(n => n.rank === 'admin')
.reduce((acc, n) => {
acc += `${n.name} ${n.lastname}, `;
return acc;
}, '').trim().replace(/,$/, '.');
document.querySelector('.result').innerText =
[...document.querySelectorAll('.sum')].reduce((acc, n) => acc + +n.innerText, 0);
document.querySelectorAll('.name').forEach((name, i) => {
name.classList.remove('name');
if (i % 2 === 0) {
name.classList.add('c1');
} else {
name.classList.add('c2');
}
});
div1 = document.createElement('div')
var div1 = document.createElement('div')
window.div1 = document.createElement('div')
useState
или useEffect
то можно и не подключать