这是我第一次在 Node.js 中创建类,我想知道为什么我不能运行这个函数……有人能给我指出正确的方向吗?
class Customer {
constructor() {
this.shoppingBasket = [];
function startShopping() {
const prompt = require("prompt-sync")();
const itemName = prompt("What item is this?");
const itemPrice = prompt("How much is it?");
const taxExemption = promt("Is this a food, book or medical product?");
console.log(`Your item is ${itemName}`);
}
}
}
Customer = Customer;
Customer.startShopping();
鸿蒙传说
相关分类