Hi,
got stuck in an exercise and i’m hopping for some help
This is the exercise:
Instructions
Write a function named getValidPassword that takes a two dimensional array as parameter.
Each entry in the first array represents a passcode. You need to find the passcode that has no odd digits and returns that passcode from your function.
Here’s an example:
var loggedPasscodes =[
[1, 4, 4, 1],
[1, 2, 3, 1],
[2, 6, 0, 8],
[5, 5, 5, 5],
[4, 3, 4, 3]
];
getValidPassword(loggedPasscodes) // returns the array: [2, 6, 0, 8]
This is what i got so far
function getValidPassword(getPasscode){
var passWord=[];
var cache=[];
for(var i=0; i<getPasscode[i].length;i++){
for(var j=0; j<getPasscode[i].length; j++){
if(getPasscode[i][j]%2===0){
cache.push(getPasscode[i][j]);
}
else{ break;}
if(getPasscode[i].length=== cache.length){
passWord= cache.slice();
}
}
}
return passWord;
}
could some one help me please!