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).
This seems to be working val[imageLink]. I think it needs to be fixed. The correct way of getting value of a key should be using quotes. Take a look at this fiddle for explanation:
https://jsfiddle.net/ro73j30s/1/
I think we need to get it fixed. Can someone else confirm it?
_help needed in triage._
/cc @FreeCodeCamp/moderators
This is an issue with the test
As @ajain17 points out val[imageLink]
does work, but only as a side effect of not escaping the .
in the Regex test, thereby letting any value replace the [
. The test needs to be re-written to strictly search for dot notation and also allow bracket notation with required quotes as in: val["imageLink"]
.
@dhcodes @raisedadead I'd like to give this a shot!
@Manish-Giri How's progress on this?
@systimotic My bad - just getting to this, been working on some of my other PRs, and then the break...
@Manish-Giri No problem! Thanks for the PR!
Most helpful comment
@dhcodes @raisedadead I'd like to give this a shot!