Build a Superhero Application Form - Step 21

Tell us what’s happening:

I believe my answer should be accepted, unless I’ve misunderstood the instruction

Your code so far

<!-- file: index.html -->

/* file: styles.css */

/* file: index.jsx */
{/* User Editable Region */}

        <button
          className='submit-btn'
          type='submit'
          disabled={!(heroName && 
                      realName && 
                      powerSource && 
                      powers.length != 0)}
        >
          Join the League
        </button>

{/* User Editable Region */}

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:139.0) Gecko/20100101 Firefox/139.0

Challenge Information:

Build a Superhero Application Form - Step 21

Hello! Remember disabled is a boolean attribute in HTML, meaning adding it basically means setting it to true. It doesn’t need a value

it looks correct, but the tests seem to accept only using ||

I’ve got the answer now… I followed a more strict reading of the “OR” in the instructions. Mine was a bit backward (although the same result.)

This should also be accepted though, I think, but did not pass the test:

disabled={!heroName || !realName || !powerSource || powers.length == 0}

@ILM Is the test a bit too strict here?

it’s already a mess already, see how long it is, to accept any order, but you can propose for the && version to be accepted too

1 Like

I get that some solutions might be better than others, but I don’t think regex is the best way to test this one. I’ll open an issue for it, thanks.

if you can propose a different way to test it, please do so in the issue

1 Like

Hello, I justencountered the same problem now

out of everything I tried, this is the only solution that worked for me:

disabled={ 
  !heroName || 
  !realName || 
  !powerSource || 
  powers.length === 0 
}

After that

I provided ChatGPT with the regex used for the test and asked to refine it. Here is what it returned:

/disabled\s*=\s*\{\s*(!\s*\(\s*heroName\s*&&\s*realName\s*&&\s*powerSource\s*&&\s*powers\.length\s*\)|(!heroName\s*\|\|\s*!realName\s*\|\|\s*!powerSource\s*\|\|\s*powers\.length\s*===\s*0))\s*\}/

However, it proposed another way freeCodeCamp could write the test logic, I didn’t understand anything about it, to be honest, but I figured it can be useful for the staff so I’ll leave the link to my Chat with ChatGPT about this here :

There’s already an open issue for this, thanks.

https://github.com/freeCodeCamp/freeCodeCamp/issues/60953

1 Like