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
ILM
June 20, 2025, 3:27pm
3
it looks correct, but the tests seem to accept only using ||
Your `button` element should have a `disabled` property.
```js
assert.match(code, /<\s*button\s+className\s*=\s*('|")\s*submit-btn\s*\1\s*type\s*=\s*('|")\s*submit\s*\2\s*disabled/)
```
You should disable the `button` if any of `heroName`, `realName`, and `powerSource` is false, or if the length of `powers` is `0`.
```js
assert.match(code, /disabled\s*=\s*\{\s*(?:!heroName\s*\|\|\s*!realName\s*\|\|\s*!powerSource\s*\|\|\s*powers\.length\s*===\s*0|!heroName\s*\|\|\s*!realName\s*\|\|\s*powers\.length\s*===\s*0\s*\|\|\s*!powerSource|!heroName\s*\|\|\s*!powerSource\s*\|\|\s*!realName\s*\|\|\s*powers\.length\s*===\s*0|!heroName\s*\|\|\s*!powerSource\s*\|\|\s*powers\.length\s*===\s*0\s*\|\|\s*!realName|!heroName\s*\|\|\s*powers\.length\s*===\s*0\s*\|\|\s*!realName\s*\|\|\s*!powerSource|!heroName\s*\|\|\s*powers\.length\s*===\s*0\s*\|\|\s*!powerSource\s*\|\|\s*!realName|!realName\s*\|\|\s*!heroName\s*\|\|\s*!powerSource\s*\|\|\s*powers\.length\s*===\s*0|!realName\s*\|\|\s*!heroName\s*\|\|\s*powers\.length\s*===\s*0\s*\|\|\s*!powerSource|!realName\s*\|\|\s*!powerSource\s*\|\|\s*!heroName\s*\|\|\s*powers\.length\s*===\s*0|!realName\s*\|\|\s*!powerSource\s*\|\|\s*powers\.length\s*===\s*0\s*\|\|\s*!heroName|!realName\s*\|\|\s*powers\.length\s*===\s*0\s*\|\|\s*!heroName\s*\|\|\s*!powerSource|!realName\s*\|\|\s*powers\.length\s*===\s*0\s*\|\|\s*!powerSource\s*\|\|\s*!heroName|!powerSource\s*\|\|\s*!heroName\s*\|\|\s*!realName\s*\|\|\s*powers\.length\s*===\s*0|!powerSource\s*\|\|\s*!heroName\s*\|\|\s*powers\.length\s*===\s*0\s*\|\|\s*!realName|!powerSource\s*\|\|\s*!realName\s*\|\|\s*!heroName\s*\|\|\s*powers\.length\s*===\s*0|!powerSource\s*\|\|\s*!realName\s*\|\|\s*powers\.length\s*===\s*0\s*\|\|\s*!heroName|!powerSource\s*\|\|\s*powers\.length\s*===\s*0\s*\|\|\s*!heroName\s*\|\|\s*!realName|!powerSource\s*\|\|\s*powers\.length\s*===\s*0\s*\|\|\s*!realName\s*\|\|\s*!heroName|powers\.length\s*===\s*0\s*\|\|\s*!heroName\s*\|\|\s*!realName\s*\|\|\s*!powerSource|powers\.length\s*===\s*0\s*\|\|\s*!heroName\s*\|\|\s*!powerSource\s*\|\|\s*!realName|powers\.length\s*===\s*0\s*\|\|\s*!realName\s*\|\|\s*!heroName\s*\|\|\s*!powerSource|powers\.length\s*===\s*0\s*\|\|\s*!realName\s*\|\|\s*!powerSource\s*\|\|\s*!heroName|powers\.length\s*===\s*0\s*\|\|\s*!powerSource\s*\|\|\s*!heroName\s*\|\|\s*!realName|powers\.length\s*===\s*0\s*\|\|\s*!powerSource\s*\|\|\s*!realName\s*\|\|\s*!heroName)\s*\}/)
```
# --seed--
## --seed-contents--
```html
<!doctype html>
<html>
<head>
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?
ILM
June 20, 2025, 3:29pm
5
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.
ILM
June 20, 2025, 3:32pm
7
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 :