sua bai tap demo

This commit is contained in:
Your Name
2026-05-15 21:42:40 +07:00
parent 6439615a3f
commit 2359deb6bb
2 changed files with 192 additions and 0 deletions

54
quan_ly_san_pham.js Normal file
View File

@@ -0,0 +1,54 @@
/* Khai báo danh sách sản phẩm, có 2 sp mẩu */
const productList = [
{
id: -1,
name: "Máy tính 1",
brand: "Asus",
price: 5000,
quantity: 5
},
{
id: -2,
name: "Máy tính 2",
brand: "Lenovo",
price: 6000,
quantity: 1
}
]
/* Khai báo 1 cái id để tự tăng sau này khi thêm product */
let genId = 0;
let choice = 0;
do {
alert(
"1/ Hiển thị danh sách product\n" +
"2/ Thêm sản phẩm\n" +
"3/ Tìm theo tên\n" +
"4/ Cập nhật thông tin\n" +
"5/ Xóa theo id\n" +
"0/ Thoát chương trình"
);
choice = +prompt("Nhập lựa chọn của bạn")
switch (choice) {
case 1:
alert(productList)
break
case 2:
break
case 3:
break
case 4:
break
case 5:
break
case 0:
break;
default:
alert("Lựa chọn không hợp lệ!")
}
} while (choice != 0)