Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

161
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!