Skrip simulasi JavaScript dan skema JSON lokal untuk pengelolaan data katalog game.
{ } example.js{ } example.json
Salin kode
JavaScript
// Konfigurasi objek data katalog lokal 6666ff
const localGameCatalog = {
platform: "6666ff" ,
region: "id" ,
activeGames: [
{ id: "195" , title: "Super Wildrix" , genre: "Slot" },
{ id: "116" , title: "Battleground" , genre: "Aksi" },
{ id: "145" , title: "Mafia Mayhem" , genre: "Slot" },
{ id: "118" , title: "Lucky Piggy" , genre: "Slot" },
{ id: "041" , title: "The Great Icescape" , genre: "Teka-teki" }
],
filterByGenre(selectedGenre) {
return this.activeGames.filter(item => item.genre === selectedGenre);
}
};
// Contoh pembacaan kategori lokal
const slotGames = localGameCatalog.filterByGenre("Slot" );
console.log("Slot terdaftar:" , slotGames.length); JSON
{
"platform" : "6666ff" ,
"region" : "id" ,
"activeGames" : [
{ "id" : "195" , "title" : "Super Wildrix" , "genre" : "Slot" },
{ "id" : "116" , "title" : "Battleground" , "genre" : "Aksi" },
{ "id" : "145" , "title" : "Mafia Mayhem" , "genre" : "Slot" },
{ "id" : "118" , "title" : "Lucky Piggy" , "genre" : "Slot" },
{ "id" : "041" , "title" : "The Great Icescape" , "genre" : "Teka-teki" }
]
}