subarray in array
by Diana Lemen
JavaScript
const A = [3, 0, 3, 0, 5, 1, 1, 2];
const B = [3, 0, 5, 1];
let test = false;
for (let j = 0; j < B.length; j++) {
if (A[j] !== B[j]) {
A.shift();
j = 0;
} else {
if (j === B.length - 1) {
test = true;
}
}
}
console.log(test)