Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

164
Vistas
How can disable only specific items in an array using their ID's?
if(event. value = "Network") {
  var opt = this. state. exportcontent
  for(conditions to be written)
  {
    condition to be written .disable= true;
  }
}

Here Network is the option that I selected through the event. export content is an array that consists of six items. I only want 1,4 and 6 id's and their values to be enabled for Network. How can I write the condition using for loop in react?

And the rest of the options should get all the 6 ids and values from export content.

I am new to React so I am expecting the values to be shown on my page.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

    var arr =  [
             {
             "customerId": 0,
             "name":"JIO",
             "isDisable": false
            },
            {
            "customerId": 1,
            "name":"ABC",
            "isDisable": false
            },
            {
            "customerId": 2,
             "name":"PQR",
            "isDisable": false
            },
            {
           "customerId": 3,
           "name":"XYZ",
           "isDisable": false
           },
          {
           "customerId": 4,
           "name":"TYE",
           "isDisable": false
           },
           {
           "customerId": 5,
           "name":"PEI",
           "isDisable": false
           },
          ];
       
   const ids = [0,3,5]; 
   const result = arr.map((obj) => {
        if(ids.includes(obj.customerId)){
          obj.isDisable = true;
      }
      return obj;
    })
    
    
console.log(result);

var arr =  [
        {
        "customerId": 1,
        "name":"ABC",
        "isDisable": false
        },
        {
        "customerId": 2,
         "name":"PQR",
        "isDisable": false
        }
      ]
   
   
arr = arr.map((obj) => {
 if(obj.customerId === 1) {
   obj.isDisable = true;
 } 
 return obj;
})

console.log(arr);

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda