Build a Superhero Application Form - Step 18

Tell us what’s happening:

Can’t get this step to pass: “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.”
Code snippet (2 options ):
const handlePowersChange = e => {
const { value, checked } = e.target;
checked ? setPowers([…powers, value])
: setPowers(powers.filter(p => p !== value))
setPowers(checked ? […powers, value] : powers.filter(p => p !== value));
}

Your code so far

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

/* file: styles.css */

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

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

    setPowers(checked ? [...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/137.0.0.0 Safari/537.36

Challenge Information:

Build a Superhero Application Form - Step 18
https://www.freecodecamp.org/learn/full-stack-developer/workshop-superhero-application-form/step-18

have you tried removing the comments? surprisingly those makes things fail sometimes

Thanks for that advice! All good now.