Skip to content

Render Images from Data Sources - Bracket Notation #12031

@alexalexson143

Description

@alexalexson143

Challenge Render Images from Data Sources has an issue.
User Agent is: Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36.
Please describe how to reproduce this issue, and include links to screenshots if possible.

My code:

<script>
  $(document).ready(function() {

    $("#getMessage").on("click", function() {$.getJSON("/json/cats.json", function(json) {

        var html = "";

        json.forEach(function(val) {
          html += "<div class = 'cat'>";

          // Only change code below this line.
          html += "<img src = '" + val["imageLink"] + "'>";
          
          // Only change code above this line.

          html += "</div>";

        });

        $(".message").html(html);

      });
    });
  });
</script>

<div class="container-fluid">
  <div class = "row text-center">
    <h2>Cat Photo Finder</h2>
  </div>
  <div class = "row text-center">
    <div class = "col-xs-12 well message">
      The message will go here
    </div>
  </div>
  <div class = "row text-center">
    <div class = "col-xs-12">
      <button id = "getMessage" class = "btn btn-primary">
        Get Message
      </button>
    </div>
  </div>
</div>

Forgive me if I don't know the correct terms. Bracket notation (val["imageLink]") not accepted as a correct solution even though clicking Get Message does the same thing with Dot Notation (val.imageLink).

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedOpen for all. You do not need permission to work on these.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions