Stuck in a exercise to enter in a coding bootcamp

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!

A few thoughts:

for(var i=0; i<getPasscode[i].length;i++){
        for(var j=0; j<getPasscode[i].length; j++){

The outer loop will stop early if loggedPasscodes has more arrays than each array does elements. Or throw an error if it has less. Given the example you supplied, [4, 3, 4, 3] will be skipped.

var loggedPasscodes =[
[1, 4, 4, 1],
[1, 2, 3, 1],
[2, 6, 0, 8],
[5, 5, 5, 5],
[4, 3, 4, 3]
];
  1. Also, try printing your cache after you push a new value to it. You’ll notice something important that you’ll need to do there.

  2. If you fix 2, you won’t need to slice anything in your code.

You almost have it, tbh.

hi there, sorry but i’m getting it :tired_face: