This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $(xml).find("enclosure").each(function(i) { | |
| console.log( $(this).attr('url') ); // note that I'm using $(this) and not i | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $(xml).find("enclosure").each(function(i) { | |
| console.log( i.attr('url') ); // -> TypeError: i.attr is not a function | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <section> | |
| <enclosure url="a" /> | |
| <other_tag> | |
| <enclosure url="b" /> | |
| </other_tag> | |
| </section> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // xml document | |
| var xml = ('<section> ' + | |
| ' <enclosure url="a"/> ' + | |
| ' <other_tag> ' + | |
| ' <enclosure url="b"/>' + | |
| ' </other_tag> ' + | |
| '</section> ' ) | |
| $(xml).find("enclosure").each(function(i) { | |
| console.log( i.attr('url') ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| bookListItem = $('<li book-id=' + id + '><a href="book.html"><h2>' + title + '</h2><p>' + realText + '</p></a></li>'); | |
| bookListItem.click(function(){ | |
| book_id = $(this).attr("book-id"); | |
| localStorage.setItem("id", book_id); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // good code | |
| getJSON("https://librivox.org/api/feed/audiobooks/title/^" + input + "?&format=json", | |
| function(url_request) { | |
| url_request.response // -> Object { books: Array[50] } | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // bad code | |
| var url_request = getJSON("https://librivox.org/api/feed/audiobooks/title/^" + input + "?&format=json"); | |
| url_request.response // -> null |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdlib.h> | |
| #include <stdio.h> | |
| struct listnode { | |
| int head; | |
| struct listnode *tail; | |
| }; | |
| struct listnode *cons(int data, struct listnode *list) { | |
| struct listnode *newlist = malloc(sizeof (struct listnode)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def get_random_number | |
| 8 ## <-- number was chosen at random | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Implementation 3 | |
| class Base | |
| def get_number | |
| raise NotImplementedError | |
| end | |
| end |