JSON APIs and Ajax: Access the JSON Data from an API

This challenge looks bugged to me:
This solution : /* json.forEach( x => x.id === 2 ? console.log(x.codeNames[1].toString()) :null) */

gives the right log (Loki), but it doesn’t pass the test. I tried to iterate the array with several other methods but it always fails.

please include challenge link

Sorry: https://www.freecodecamp.org/learn/data-visualization/json-apis-and-ajax/access-the-json-data-from-an-api

you do not need to do one thing for each element of the array, the challenge expects you to use just bracket and dot notation to access the right value

That’s an array, in some way you do have to iterate on it to pick the object you want…

but you know the one you want, it is the third element in the array
you do not need to iterate over the array to extract a specific element

Oh lol, my bad, too used to real world fetch… Thanks :slight_smile:

1 Like

if you are already familiar with this stuff, maybe just jump to the projects! it’s the only part you need to do to get a cert

Oh thanks for the tip, I thought I had to complete all the steps too! I’m not very experienced, but I did some projects by fetching data on endpoints and usually they are so big that you iterate on them you don’t pick items directly, so I was keeping doing that :slight_smile: