Steps For Accessing the JSON Data From An API

What is your hint or solution suggestion?

Break the challenge down in parts:

1st , we know we are going to access the value using the json const variable and log it,
so let’s code for that:


2nd, we want to target the object with an id of 2 (which just so happens to be it’s index number) in the json array data…
so let’s code for that:
(Remember: access array values with brackets and it’s index number)


3rd, we want to access the codenames array that’s in the object we just accessed.
(Remember, access object values by using dot notation on their key/property/identifier)
Let’s add that to our code:


4th, we want the 2nd value in the codenames array and since you remember how to access array values which was previously demonstrated above, let’s do that:
Hint: what index value does the 2nd array value have?


And now you’re done :slightly_smiling_face:

Challenge: Access the JSON Data from an API

Link to the challenge:

1 Like