Access the JSON Data from an API Challenge

Tell us what’s happening:

Im on the Access the JSON Data from an API challenge and it seems to be working as expected with the output but is not passing the test. Has anybody else gotten this challenge to pass? Im not sure if it’s the way I did it or maybe if its bugged?

Your code so far

      req=new XMLHttpRequest();"GET",'/json/cats.json',true);
        // Add your code below this line
        console.log(json.find(item => == 2).codeNames[1])
        // Add your code above this line
  body {
    text-align: center;
    font-family: "Helvetica", sans-serif;
  h1 {
    font-size: 2em;
    font-weight: bold;
  .box {
    border-radius: 5px;
    background-color: #eee;
    padding: 20px 5px;
  button {
    color: white;
    background-color: #4791d0;
    border-radius: 5px;
    border: 1px solid #4791d0;
    padding: 5px 10px 8px 10px;
  button:hover {
    background-color: #0F5897;
    border: 1px solid #0F5897;
<h1>Cat Photo Finder</h1> 
<p class="message box">
  The message will go here
  <button id="getMessage">
    Get Message

It does say

You should use bracket and dot notation on the object (which is saved in the variable json) to access the value.

in the challenge so I tried a more round about way of doing it but it also didn’t pass the test.

let i = json.findIndex(item => == 2);

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36.

Link to the challenge:

1 Like

It looks like you’ve gone above and beyond the test’s expecatations by using the find method (good on you though!) you can pass this test by the following line:


1 Like