Object.values(obj).some(value => !value);
(Object.values(obj).filter(value => !value)).length
function toggleFullScreen() {
if (!document.fullscreenElement && // alternative standard method
!document.mozFullScreenElement && !document.webkitFullscreenElement) { // current working methods
if (document.documentElement.requestFullscreen) {
document.documentElement.requestFullscreen();
} else if (document.documentElement.mozRequestFullScreen) {
document.documentElement.mozRequestFullScreen();
} else if (document.documentElement.webkitRequestFullscreen) {
document.documentElement.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
}
return true
} else {
if (document.cancelFullScreen) {
document.cancelFullScreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.webkitCancelFullScreen) {
document.webkitCancelFullScreen();
}
return false
}
}
toggleFullScreen() && document.body.style.display = ('none');
function toggleFullScreen() {
if (!document.fullscreenElement && // alternative standard method
!document.mozFullScreenElement && !document.webkitFullscreenElement) { // current working methods
if (document.documentElement.requestFullscreen) {
document.documentElement.requestFullscreen() && return true;
} else if (document.documentElement.mozRequestFullScreen) {
document.documentElement.mozRequestFullScreen() && return true;
} else if (document.documentElement.webkitRequestFullscreen) {
document.documentElement.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT) && return true;
}
} else {
if (document.cancelFullScreen) {
document.cancelFullScreen() && return false;
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen() && return false;
} else if (document.webkitCancelFullScreen) {
document.webkitCancelFullScreen() && return false
}
}
}
toggleFullScreen() && document.body.style.display = ('none');
//var initialData = [1, 9, 4, 95, -3, 51, 6, 9, 4, 4,-9, 88, 27];
var initialData = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2];
var wayFirst = function(data) {
var sum = 0;
data.forEach( (value) => {sum = sum + value} )
return sum;
}
var waySecond = function(data) {
var sum = 0;
data.forEach( (value, i) => {
i % 2 === 0 ? sum = sum + value : false
})
return sum;
}
var wayThird = function(data) {
var sum = 0;
var iTemp = 0
data.forEach( (value, i) => {
if (!iTemp || iTemp + 4 === i) {
sum = sum + value;
iTemp === 0 ? iTemp = 1 : iTemp = i;
}
})
return sum;
}
console.log(wayFirst(initialData));
console.log(waySecond(initialData))
console.log(wayThird(initialData))
const initialData = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]
let sumArrayWithInterval = (data, interval) => {
const sumWithIntervel = [];
let next = 0;
data.forEach((value, i) => {
if (next === i) {
const valueIndex = interval === 1 ? 1 + i : interval + 1 + i;
data[valueIndex] ? sumWithIntervel.push(value + data[valueIndex]) : false
interval === 1 ? next = i + interval + 1 : next = valueIndex + 1
}
})
return sumWithIntervel;
}
console.log(
sumArrayWithInterval(initialData, 1)
);
console.log(
sumArrayWithInterval(
sumArrayWithInterval(initialData, 1)
, 2)
);
console.log(
sumArrayWithInterval(
sumArrayWithInterval(
sumArrayWithInterval(initialData, 1)
, 2)
, 4)
);
testDecorator = function(func1, func2) { return function(a, b) { return func1( func2(a, b) ) } }
func1 = a => return a * a
func2 = (a, b) => { return a + b }
countSome = testDecorator(func1, func2)
countSome(2, 2); // 16
countSome(2, 3); // 25
var a = new F();
var b = new F();
alert(a == b);
function F() {
if (F.instance) {
return F.instance
}
F.instance = this;
}