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

158
Views
cómo modificar datos existentes, usando la condición if con JSON

Soy un programador novato que estoy aprendiendo JSON y quiero hacer una pregunta sobre cómo cambiar los datos e imprimirlos.

según la condición si la puntuación es > 5, el estado cambia de no publicado a publicado

 let data = [ { title: "The Only Guide You Need", score:8, status: "Posted" }, { title: "The Advanced Guide To Archive", score:5, status: "Unposted" }, { title: "In Defense of the Figurative Use of Literally.", score:6, status: "Unposted", }, ] console.log(data)

**gracias de antemano

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Simplemente use Array.prototype.map para recorrer cada elemento. Si la puntuación es superior a 5, establezca el status en "Posted"

 let data = [ { title: "The Only Guide You Need", score:8, status: "Posted" }, { title: "The Advanced Guide To Archive", score:5, status: "Unposted" }, { title: "In Defense of the Figurative Use of Literally.", score:6, status: "Unposted", }, ] data = data.map((current) => { if (current.score > 5) current.status = "Posted"; return current; }); console.log(data)

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!