From bd1eb104ac3bc55666c3247d75ba4d363b9f9bf9 Mon Sep 17 00:00:00 2001 From: Ben McMahon Date: Thu, 29 Oct 2015 21:07:51 +0000 Subject: [PATCH] Update json-apis-and-ajax.json --- seed/challenges/json-apis-and-ajax.json | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/seed/challenges/json-apis-and-ajax.json b/seed/challenges/json-apis-and-ajax.json index ea3a4351e2..e4eb407d97 100644 --- a/seed/challenges/json-apis-and-ajax.json +++ b/seed/challenges/json-apis-and-ajax.json @@ -167,9 +167,7 @@ "Here's the code that does this:", "json.map(function(val) {", "  html = html + \"<div class = 'cat'>\"", - "  for(var key in val) {", - "    html = html + '<div class = \"' + key + '\">' + val[key] + '</div>';", - "  }", + "  html = html + '<div>' + val + '</div>';", "  html = html + \"</div><br/>\"", "});" ], @@ -229,14 +227,12 @@ "In the JSON that we receive from Free Code Camp's Cat Photo API, each object has an attribute called \"imageLink\".", "When we're looping through these objects, let's check whether an object attribute (key) is imageLink. If it is, instead of outputing the image link, let's render the image.", "Here's the code that does this:", - "if(key === \"imageLink\") {", - "  html = html + '<img class = \"' + key + '\"src = \"' + val[key] + '\">';", - "} else {", - "  html = html + '<div class = \"' + key + '\">' + val[key] + '</div>';", + "if(val.match(\"http\")) {", + "  html = html + '<img src = \"' + val + '\">';", "}" ], "tests": [ - "assert(editor.match(/imageLink/gi), 'You should have accessed the imageLink of each cat object.')" + "assert(editor.match(/val.match/gi), 'You should have accessed the imageLink of each cat object.')" ], "challengeSeed": [ "fccss", @@ -251,16 +247,12 @@ "", " html = html + \"
\"", "", - " for (var key in val) {", - "", " // Only change code below this line.", "", "", "", " // Only change code above this line.", "", - " }", - "", " html = html + \"
\"", "", " });", @@ -328,11 +320,7 @@ "", " // Only change code above this line.", "", - " for(var key in val){", - "", - " html = html + '
' + val[key] + '
';", - "", - " }", + " html = html + '
' + val + '
';", "", " html = html + \"\"", "",