commit
436770c0a7
|
@ -167,9 +167,7 @@
|
|||
"Here's the code that does this:",
|
||||
"<code>json.map(function(val) {</code>",
|
||||
"<code>  html = html + \"<div class = 'cat'>\"</code>",
|
||||
"<code>  for(var key in val) {</code>",
|
||||
"<code>    html = html + '<div class = \"' + key + '\">' + val[key] + '</div>';</code>",
|
||||
"<code>  }</code>",
|
||||
"<code>  html = html + '<div>' + val + '</div>';</code>",
|
||||
"<code>  html = html + \"</div><br/>\"</code>",
|
||||
"<code>});</code>"
|
||||
],
|
||||
|
@ -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 <code>imageLink</code>. If it is, instead of outputing the image link, let's render the image.",
|
||||
"Here's the code that does this:",
|
||||
"<code>if(key === \"imageLink\") {</code>",
|
||||
"<code>  html = html + '<img class = \"' + key + '\"src = \"' + val[key] + '\">';</code>",
|
||||
"<code>} else {</code>",
|
||||
"<code>  html = html + '<div class = \"' + key + '\">' + val[key] + '</div>';</code>",
|
||||
"<code>if(val.match(\"http\")) {</code>",
|
||||
"<code>  html = html + '<img src = \"' + val + '\">';</code>",
|
||||
"<code>}</code>"
|
||||
],
|
||||
"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 + \"<div class = 'cat'>\"",
|
||||
"",
|
||||
" for (var key in val) {",
|
||||
"",
|
||||
" // Only change code below this line.",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
" // Only change code above this line.",
|
||||
"",
|
||||
" }",
|
||||
"",
|
||||
" html = html + \"</div>\"",
|
||||
"",
|
||||
" });",
|
||||
|
@ -328,11 +320,7 @@
|
|||
"",
|
||||
" // Only change code above this line.",
|
||||
"",
|
||||
" for(var key in val){",
|
||||
"",
|
||||
" html = html + '<div class = \"' + key + '\">' + val[key] + '</div>';",
|
||||
"",
|
||||
" }",
|
||||
" html = html + '<div>' + val + '</div>';",
|
||||
"",
|
||||
" html = html + \"</div>\"",
|
||||
"",
|
||||
|
|
Loading…
Reference in New Issue