i have a problem that i am not yet able to solve that is asked for me to create a function.
the exercise goes like this:
Write a function named getValidPassword that takes a two dimensional array as parameter.
Each entry in the array represents a passcode. You need to find the passcode that has no odd digits and return it 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, 8],
[4, 3, 2, 3, 9]
];
getValidPassword(loggedPasscodes) // returns the array: [2, 6, 0, 8]
my code is:
function getValidPassword (loggedPasscodes){
for(let i= 0; loggedPasscodes.length > i;i++){
let passcode = loggedPasscodes [i];
for (let j = 0;passcode.length > j; j++){
if(passcode [j] % 2 !== 0){
break;
}
}
return passcode;
}
}
var loggedPasscodes=[
["1","4","4","1"],
["1", "2", "3", "1"],
["2","6", "0","8"],
["5", "5", "5", "5"],
["4","3", "4", "3"],
];
console.log(getValidPassword(loggedPasscodes));
and i get the error:
Code is incorrect
Function getValidPassword is not working as requested.
[
“1”,
“4”,
“4”,
“1”
]
can someone help?