Home > front end >  How can I remove a certain value in a flatmap?
How can I remove a certain value in a flatmap?

Time:02-10

This is the flatmap:

 const options = names.flatMap(
    (object) => object.name   " - "   object.size   "- "   object.category
  );

console.log(options):

enter image description here

If the object.category is equals to S-XL how can I not display its values? But if the object.category is equals too ft it will display the object.category ?Any help would be appreciated. Thank you

I'll be using the flatMap here:

<Autocomplete
        disablePortal
        isOptionEqualToValue={(option, value) => option?.label === value?.label}
        id="combo-box-demo"
        options={options}
        fullWidth
        value={value}
        onChange={onChange}
        renderInput={(params) => <TextField {...params} label="Products" />}
        required
      />

CodePudding user response:

  const options = names.flatMap(
      (object) => 
               object.name   
               " - "   
              object.size   
              `${object.category == "ft" ? "- "   object.category : ""}`
    );
  •  Tags:  
  • Related