Mẫu cấu hình phân loại danh mục trò chơi trên nền tảng.
{ } gameCatalog.js{ } gameCatalog.json
Sao chép mã
JavaScript
// Cấu hình danh mục trò chơi mb661 trên giao diện cục bộ
const localGameCatalog = [
{ id: "027" , name: "Baccarat Deluxe" , category: "Game bài" },
{ id: "077" , name: "Jewels Prosper" , category: "Slot game" },
{ id: "064" , name: "Phoenix Rises" , category: "Slot game" },
{ id: "137" , name: "Fruity Candy" , category: "Slot game" },
{ id: "022" , name: "Legend Of Hou Yi" , category: "Slot game" }
];
function getGamesByCategory(categoryName) {
return localGameCatalog.filter(game => game.category === categoryName);
}
// Kết quả lọc danh mục cục bộ
const slotGames = getGamesByCategory("Slot game" );
console.log("Số trò chơi slot:" , slotGames.length); JSON
{
"catalog" : [
{
"id" : "027" ,
"name" : "Baccarat Deluxe" ,
"category" : "Game bài"
},
{
"id" : "077" ,
"name" : "Jewels Prosper" ,
"category" : "Slot game"
},
{
"id" : "064" ,
"name" : "Phoenix Rises" ,
"category" : "Slot game"
},
{
"id" : "137" ,
"name" : "Fruity Candy" ,
"category" : "Slot game"
},
{
"id" : "022" ,
"name" : "Legend Of Hou Yi" ,
"category" : "Slot game"
}
]
}