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

223
Views
How can I find a certain Index of a JSON array based on its content? (Javascript)

My JSON-File is:

[
    {
        "date":"2022-W04",
        "moods":[
            {"mood":4,"name":"Dennis"},
            {"mood":3,"name":"Kevin"},
            {"mood":3,"name":"Alexandros"},
            {"mood":2,"name":"Tobias"},
            {"mood":0,"name":"Andreas"}
        ]
    },
    {
        "date":"2022-W05",
        "moods":[
            {"mood":0,"name":"Dennis"},
            {"mood":0,"name":"Kevin"},
            {"mood":3,"name":"Alexandros"},
            {"mood":2,"name":"Tobias"},
            {"mood":0,"name":"Andreas"}
        ]
    }
]

I now want to have the index for example for date 2022-W05 to access its data(mood and name). Of course I could just loop through the entire array and check for the correct date but is there a better way to get the right index?

about 4 years ago · Juan Pablo Isaza
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!