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

  $(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>";




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

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:

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.

When you get to some of the projects you will be using the getJSON functionality and will probably have to learn even more about it in depth to accomplish some of the projects. This particular challenge was not really meant to teach you about getJSON, but instead was meant to expose you to some new and how to dynamically create the html necessary to display an image. The “something new” is there in the hopes you might do further research on your own just out of curiosity.

1 Like