How do you learn when the code is given to you?

Tell us what’s happening:
A little concerned that the code is just being provided but not explained. Wondering how I’m supposed to learn if I might as well just copy and paste.

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='" +
          va;.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 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36.

Link to the challenge:
https://www.freecodecamp.org/challenges/render-images-from-data-sources

It’s just as important to know how to build your own code than to know how to read code that it’s already implemented.
By now, you should have learned the basic skills to understand what this code does.
When you start working on your new job, you are gonna find lot of code written by other programmers. May be your are luckly enough, and they still work on the Company, and they can help you if there is something you don’t undesrtand. But in other cases, you’ll find code that nobody is gonna explain you how it works.
Also, you must learn how to modify code that need improvements, so you must get the skills to scroll through the whole code.

1 Like

Correct. I can certainly follow along and understand how the code works and where/why/how it’s pulling info. Nevertheless I remain curious to know how certain commands were derived and if any aspects are interchangeable or if they are just standard commands meant to be repeated in order to get a specific outcome.