Ad
  • Custom User Avatar

    I added console.log('input = ', arr) at the beginning of your function and console.log('output = ', result) at the end, here is what I see:

    input =  [ '', '', '', 'a', '', '' ]
    output =  undefined
    

    your function fails that tests case because your result variable is never assigned a value: the 3 consecutive ifs are not entered, then masterKey === [], so the loop is not entered either, so result remains undefined.