Skip to content

Instantly share code, notes, and snippets.

@erhanyasar
Last active Jun 4, 2020
Embed
What would you like to do?
Some Quiz Questions Solved
let A = [4,12,9,5,6,1],
B = [4,9,12,6];
function findMissing(A, B){
let missingElements = [];
for (var i=0; i<A.length; i++){
for (var j=0; j<B.length; j++){
if (A[i] == B[j])
break;
else {
if (j == (B.length-1)){
missingElements.push(A[i]);
}
}
}
continue;
}
console.log(missingElements);
return missingElements;
}
findMissing(A, B);
function fizzBuzz(n) {
for (let i=1; i<n+1; i++){
if (i % 15 == 0)
console.log("FizzBuzz");
else if (i % 5 == 0)
console.log("Buzz");
else if (i % 3 == 0)
console.log("Fizz");
else
console.log(i);
}
}
let A = [1, 2, 3, 4, 5, 6],
B = 8;
function rotate(A, B){
let arr = A,
rotatedArray = [],
shifted;
for (let i = 0; i < B; i++){
shifted = arr.shift();
rotatedArray = arr;
rotatedArray.push(shifted);
}
console.log(rotatedArray);
console.log(A, arr);
return rotatedArray;
}
rotate(A, B);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment