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

135
Views
Javasript Changing values ​by selecting only true values ​from among array values

I want to change the value of AdditionalShipping when button onChange occurs only to the values ​​in which select is true among the array values ​​in additionalShippingArray.

console.log(additionalShippingArray)

0: {select: false, key: 1, AdditionalShipping: 0}
1: {select: true, key: 2, AdditionalShipping: 0}
2: {select: false, key: 3, AdditionalShipping: 0}

I want to put 5000 in AdditionalShipping only if the additionalShippingCost value is additionalShippingArray select true .

const [additionalShippingCost, setAdditionalShippingCost] = useState<number>(5000);

I want the button to be onClick and applied when the onClickBatchApplication function is called. What should I do?

  const onClickBatchApplication = () => {
    
  };

   return (
     <button onClick={onClickBatchApplication}>apply</button>
)
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I think this might work

  const onClickBatchApplication = () => {
    setAdditionalShippingArray(prev => prev.map((i)=> {
    if(i.select) {
    return {...i, AdditionalShipping :additionalShippingCost }
    }else{
    return i
    }
    })

  };

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!