Cấu hình danh mục trò chơi mẫu dạng JavaScript và JSON để quản lý trải nghiệm cục bộ.
{ } example.js{ } example.json
Sao chép mã
JavaScript
// Khai báo đối tượng danh sách trò chơi n188 cục bộ
const localGameLibrary = {
platform: "n188" ,
country: "vn" ,
categories: ["Slot game" ],
items: [
{ id: "148" , name: "Dragon Hatch2" , type: "Slot game" },
{ id: "194" , name: "Mighty Mania" , type: "Slot game" },
{ id: "160" , name: "Yakuza Honor" , type: "Slot game" },
{ id: "165" , name: "Rio Fantasia" , type: "Slot game" },
{ id: "080" , name: "Jack Frosts" , type: "Slot game" }
],
filterByCategory: function (categoryName) {
return this.items.filter(game => game.type === categoryName);
}
};
// Ví dụ kiểm tra danh sách đã lọc
const slotGames = localGameLibrary.filterByCategory("Slot game" );
console.log("Số lượng trò chơi tìm thấy:" , slotGames.length); JSON
{
"platform" : "n188" ,
"country" : "vn" ,
"supported_platforms" : ["android" ],
"games" : [
{
"id" : "148" ,
"name" : "Dragon Hatch2" ,
"category" : "Slot game"
},
{
"id" : "194" ,
"name" : "Mighty Mania" ,
"category" : "Slot game"
},
{
"id" : "160" ,
"name" : "Yakuza Honor" ,
"category" : "Slot game"
},
{
"id" : "165" ,
"name" : "Rio Fantasia" ,
"category" : "Slot game"
},
{
"id" : "080" ,
"name" : "Jack Frosts" ,
"category" : "Slot game"
}
]
}