100 Days of Code: Day 11
Worked a while on my Wikipedia Viewer…about 4 hours worth. But I did make some progress today. With the help of my fellow campers on the FreeCodeCamp forum, I was able to finally get the urls showing up in my search. They’re all on one line since I’m referencing the array they’re in, but they’re on the screen so I call that a win.
I think I may know what I need to do to get the search title and snippet showing up, along with being able to wrap the snippet in the url thats provided from the search. And unfortunately I think it’s going to be a for loop that I’ll need to use to be able to get the information showing up correctly.
Basically, I need to go through each loop, tell it to put the title of the search result in an <h3> tag, followed by the snippet in a <p> tag, and have the whole thing wrapped in an <a> tag. Or have a link under the snippet to get to the Wikipedia page. My guess it will look something like this:
for (i = 0; i < json[i].length; i++){
var heading = ‘<h3>’ + json[1]+ ‘</h3>’;
var snippet = ‘<p>’ + json[2] + ‘</p>’;
var page = json[3];
$(‘#results’).append(heading + ‘<br/>’ + snippet + ‘<br/>’ + page);
}
Or something like this anyway. But that’s something for me to work on at a later time dear readers. So for now, stay classy, be awesome, and code on!