Return value
The new length property of the object upon which the method was called.
filteredArray([[1, 2, 3], [3, 2, 1], [2, 4, 6]], 3);
// [[2, 4, 6]]
setTimeout(
() => { sliderChange(document.querySelectorAll('.swiper-slide img')); },
500
);
.strictEqual(actual, expected, [message])
Asserts strict equality (===) of actual and expected.
[1, 2, 3] === [1, 2, 3] // false
function countContiguousDistinct(k, arr) {
const counts = [];
let distinct = 0;
const result = [];
for (let i = 0; i < k; i += 1) {
const val = arr[i];
if (counts[val] === undefined) {
counts[val] = 0;
distinct += 1;
}
counts[val] += 1;
}
result.push(distinct);
for (let i = k; i < arr.length; i += 1) {
const lVal = arr[i - k];
counts[lVal] -= 1;
if (counts[lVal] === 0) {
distinct -= 1;
}
const rVal = arr[i];
if (counts[rVal] === undefined) {
counts[rVal] = 0;
}
if (counts[rVal] === 0) {
distinct += 1;
}
counts[rVal] += 1;
result.push(distinct);
}
return result;
}