Intermediate Algorithm Scripting: Steamroller code validation issue?

I think the validator is checking for any variation of ‘flat’ in the code, because I changed flatten to squish and got my previous code to pass the last test.

New code:

function steamrollArray(arr) {
  let results = []
  function squish(item) {
    if(!Array.isArray(item)){
      results.push(item)
    } else {
      item.forEach(squish)
    }
  }
  arr.forEach(squish)
  return results
}
1 Like