Build a Superhero Application Form - Step 18

Tell us what’s happening:

I have written the Powers setter function as it’s described. how It keep giving the same error message like:

You should use a ternary operator to check if “checked” is true. If it is, spread in the existing “powers” and “value” into an array. If it is not, filter out the “value” from "powers

Your code so far

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

/* file: styles.css */

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

  const handlePowersChange = e => {
    const { value, checked } = e.target;
    setPowers(powers => checked===true ? [...powers, value] : powers.filter(p => p !== value));

  }

{/* User Editable Region */}

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36

Challenge Information:

Build a Superhero Application Form - Step 18

GitHub Link: freeCodeCamp/curriculum/challenges/english/blocks/workshop-superhero-application-form/68149b101d905a6fc2fcd6d8.md at main · freeCodeCamp/freeCodeCamp · GitHub

hello @marufbs welcome to the forum!

did the instructions ask to pass a function to setPowers or an expression?

also you do not need to explicitly check checked === true, just passing checked in the boolean context should do the job.