JSFiddle - React, Tailwind, and code Playground
by Karl Hui
JavaScript
var library = {
"name": "The Great Library of Alexandria",
"books": [{
"isbn": "94234-123A",
"title": "Of Mice and Men",
"pages": 102,
"author": "John Steinbeck",
"languages": ["english", "french (translated)"],
"price": 10.99
}, {
"isbn": "64128-341J",
"title": "lololol",
"pages": 183,
"author": "Jane Doe",
"languages": ["english", "spanish", "Urdu"],
"price": 5.99
}, {
"isbn": "31853-318E",
"title": "roflcopters",
"pages": 318,
"author": "Steve Rogers",
"languages": ["english", "Urdu", "Binary", "spanish", "french"],
"price": 22.49
}, {
"isbn": "13812-108W",
"title": "The Rock Says",
"pages": 180,
"author": "Dwayne Johnson",
"languages": ["english", "French (Translated)", "Binary"],
"price": 25.44
}, {
"isbn": "04830-761T",
"title": "I Pity the Fool",
"pages": 706,
"author": "Mr. T",
"languages": ["English"],
"price": 73.68
}, {
"isbn": "60847-360K",
"title": "Time to Play the Game",
"pages": 094,
"author": "Paul Leveque",
"languages": ["french", "binary"],
"price": 904.00
}
]
};
//adds field and change author field
//Quick note: the ordering is not enforced; don't expect these properties to be in the same order you put them in above
var summerReading = [];
for (var key in library) {
//console.log("The key is " + key + " and that value is " + library[key]);
if (key === "books") {
for (var i = 0; i < library[key].length; i++) {
summerReading.push(library[key][i].title);
console.log(summerReading);
//console.log("This book's name is: " + library[key][i].title);
...