Freecodecamp: steamroller fifth test fails for function names containing flat

Created on 21 Apr 2020  路  3Comments  路  Source: freeCodeCamp/freeCodeCamp


Edit: sorry, same as #38491
Describe your problem and how to reproduce it:
The fifth test for Steamroller algorithm fails for function names containing flat

Your solution should not use the Array.prototype.flat() or Array.prototype.flatMap() methods.

const flatten = array => { } // this will fail the fifth test
function steamrollArray(arr) {
  return arr; // even without the function call
}

Add a Link to the page with the problem:
Intermediate Algorithm Scripting: Steamroller

Tell us about your browser and operating system:

  • Browser Name: Chrome
  • Browser Version: v81
  • Operating System: Windows 10

If possible, add a screenshot here (you can drag and drop, png, jpg, gif, etc. in this box):
image

learn needs help for triage

All 3 comments

@piouson, awesome, great catch here. The issue seems to be with this testString, which is a bit too flexible:

testString: assert(!code.match(/\.?[\s\S]*?flat/) && !code.match(/\.?[\s\S]*?flatMap/));

For some reason . characters before flat or flatMap are optional. This could be changed to ensure that we're only catching those array methods, not other variables, functions, or even comments that include "flat".

My bad @scissorsneedfoodtoo same as #38491 and #38497

@piouson, ah, I didn't notice those other ones. Thanks for bringing this up, though! It's definitely something we want to fix.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ar5had picture ar5had  路  3Comments

imhuyqn picture imhuyqn  路  3Comments

kokushozero picture kokushozero  路  3Comments

robwelan picture robwelan  路  3Comments

SaintPeter picture SaintPeter  路  3Comments