JSFiddle - React, Tailwind, and code Playground
by Jesus Trejo
JavaScript
var games = [{
title: "Kingdom Heart2",
players: "1",
platform: "PS2",
publisher: "SquareEnix",
category: "RPG",
reception: {
gamerankings: "87%",
metacritic: "87%"
},
series: "Kingdom Heart"
}, {
title: "Injustice: Gods Among Us",
players: "1, 2",
platform: ["PS3", "Xbox360", "WiiU"],
publisher: "WB Games",
category: "Fighting",
reception: {
gamerankings: "82%",
metacritic: "81%"
},
series: "none"
}, {
title: "Spec Ops: The Line",
players: "1",
platform: ["PC", "PS3", "Xbox360"],
publisher: "2K Games",
category: "Action",
reception: {
metacritic: "77%",
ign: "80%"
},
series: "none"
}, {
title: "Harvest Moon: Grand Bazaar",
players: "1",
platform: "NDS",
publisher: "Natsume",
category: "Simulation",
reception: {
gamerankings: "70%",
nintendopower: "60%"
},
series: "Harvest Moon"
}];
var titles = function (obj) {
for (var prop in obj) {
alert(prop);
}
};
var search = function(name) {
for(var prop in games) {
if(games[prop].title === name) {
alert(games[prop]);
return games[prop];
}
}
};
titles(games[0]);
search("Harvest Moon Grand Bazaar");