question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Convert JSON Data to HTML doesn't call for "message button to be pressed" to pass

See original GitHub issue

Challenge Convert JSON Data to HTML has an issue. User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/601.5.17 (KHTML, like Gecko) Version/9.1 Safari/601.5.17. 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 = "";
        // Only change code below this line.
        json.forEach(function(val) {
          var keys = Object.keys(val);
          html += "<div class = 'cat'>";
          keys.forEach(function(key) {
          html += "<b>" + key + "</b>: " + val[key] + "<br>";
          });
          html += "</div><br>";
          });


        // Only change code above this line.

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

The student doesn’t have to press the button and see the updated output before the test is passed and therefore doesn’t see what the output would be. Suggest to update instructions to tell the student to click the message button at least and if possible don’t pass them unless they have.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
theoneinskanecommented, May 26, 2016

@raisedadead maybe just start with the instruction to click message?

0reactions
lawfetscommented, Dec 2, 2016

I don’t know if I can put this here but if you make a mistake in the html code that can be copy-pasted into the right position, it still validates the test, although there’s a major mistake in the coding and if you press the button nothing happens. for instance : if you remove <html += “<div class = ‘cat’>”;> the test passes but there’s no output due to the problems created in the html code that is being produced.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Convert JSON Data to HTML doesn't call for "message button ...
The student doesn't have to press the button and see the updated output before the test is passed and therefore doesn't see what...
Read more >
How to send a JSON object using html form data
Get complete form data as array and json stringify it. var formData = JSON.stringify($("#myForm").serializeArray());.
Read more >
JavaScript JSON parse() Method - W3Schools
The JSON.parse() method parses a string and returns a JavaScript object. The string has to be written in JSON format. The JSON.parse() method...
Read more >
How to Use the Fetch API (Correctly) - CODE Magazine
Navigate into the folder Samples-WebAPI and load that folder in Visual Studio Code or Visual Studio 2019. Open the appsettings.json file and ...
Read more >
How to Convert HTML Form Field Values to a JSON Object
The FormData API doesn't directly convert form values to JSON, but we can get there by using the entries method and passing its...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found