我目前正在对javascript进行codecademy简介。
const takeOrder = (topping) => {
console.log('Order: pizza topped with ${topping}');
};
takeOrder("mushrooms");
不应该这样做而不是
const takeOrder = (topping) => {
console.log('Order: pizza topped with' +topping);
};
takeOrder("mushrooms");
我不知道为什么我不能这样插入?
答案 0 :(得分:0)
console.log('Order: pizza topped with ${topping}');
不应该这样做
没有。您希望反引号使用字符串模板文字
const takeOrder = (topping) => {
console.log(`Order: pizza topped with ${topping}`); //NB `
};
takeOrder("mushrooms");