function sum(arr) {
let result = 0;
for (let i = (arr.length - 1); i !== 0; i--) {
if (arr[i] === 0) return result;
result += Math.abs(arr[i]);
}
return result;
}
console.log(sum([2.1, 3.1, 4.1, 6.1, 7.1, 9.1, 11.1, 0.0, 2.2, 1.4])); // 3.6
console.log(sum([2.1, 3.1, 4.1, 6.1, 7.1, 9.1, 11.1, 0.0])); // 0
const electricDate = document.querySelector(".electronic__date");
const electricTime = document.querySelector(".electronic__clock");
setInterval(checkDateAndTime, 1000);
function checkAddZero(num) {
return num < 10 ? "0" + num : num
}
function checkDateAndTime() {
const DATE = new Date();
const week = ["ВС", "ПОН", "ВТ", "СР", "ЧТ", "ПТ", "СУБ"];
let year = DATE.getFullYear();
let month = checkAddZero(DATE.getMonth() + 1);
let day = checkAddZero(DATE.getDate());
let hour = checkAddZero(DATE.getHours());
let minute = checkAddZero(DATE.getMinutes());
let second = checkAddZero(DATE.getSeconds());
electricDate.innerHTML = year + "-" + month + "-" + day + " " + week[DATE.getDay()];
electricTime.innerHTML = hour + ":" + minute + ":" + second;
}
$('.menu__item').click(function(){
$('.menu__item.active').removeClass('active');
$(this).addClass('active');
// как и в ответе выше, рекомендую удалить
if($(this).hasClass('active')){
$(this).css({'background': 'linear-gradient(90deg, rgba(255,0,0,1) 0%, rgba(136,0,255,1) 1%, rgba(255,0,0,1) 100%)'});
$(this).next('.sub_menu__list').css({'opacity': 1, 'visibility': 'visible'});
} else{
$(this).css({'background': 'inherit'});
$(this).next('.sub_menu__list').css({'opacity': 0, 'visibility': 'hidden'});
}
})
data.map(item => (
<option key={item.id} selected={item.year === 2020}>{item.year}</option>
))