Image not showing

Image not showing
0.0 0

#1

Tell us what’s happening:
Why is the image not showing, but still I can advance to the next challenge? Thanks

Your code so far

<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 + "' " + "alt ='" + val.altText + "'>";
          
          
          // 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>

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:60.0) Gecko/20100101 Firefox/60.0.

Link to the challenge:


#2


#3

Man, this took me a while to find. The line:

html =+ "<img src = '" + val.imageLink + "' " + "alt ='" + val.altText + "'>";

That assignment operator, there is no operator =+, you’ve transposed them - it’s +=.


#4

Thanks so much! I spent hours too, trying to spot the problem, and changing the code, but I never realized that!
It is weird that I was allowed to go on to the next challenge, even with the mistake, though.


#5

Hi Jacey. Thanks, but of course that I had clicked the button. It just gave me a mistake message instead of an image because of the misspelled operator += (=+), as @kevinSmith pointed out.
Thanks for the answer, anyway!