【发布时间】:2021-02-16 14:05:51
【问题描述】:
创建一个接受字符串的函数makePlans。这个字符串应该是一个名字。 makePlans 函数应该调用 callFriend 函数并返回结果。 callFriend 接受一个布尔值和一个字符串。将 friendsAvailable 变量和名称传递给 callFriend。
创建一个接受布尔值和字符串的函数callFriend。如果布尔值为真,callFriend 应返回字符串'Plans made with NAME this week'。否则它应该返回'本周末大家都很忙'。
到目前为止,这是我想出的: 让friendsAvailable = true;
function makePlans(name) {
// INSERT CODE HERE
return `Plans made with ${name} this weekend`;
}
function callFriend(bool, name) {
// INSERT CODE HERE
if (callFriend = true); {
return 'Plans made with ${name} this weekend';
} else (callFriend = false) {
return "Everyone is busy this weekend";
}
}
// Uncomment these to check your work!
console.log(makePlans("Mary")) // should return: "Plans made with Mary this weekend'
friendsAvailable = false;
console.log(makePlans("James")) //should return: "Everyone is busy this weekend."
我无法确定要更正的内容,控制台告诉我存在语法错误:意外标记“else”
【问题讨论】:
-
我认为
if (callFriend = true);之后的分号是你的问题。此外,通常在您发布问题时用您使用的语言标记您的问题会很有帮助。
标签: string function if-statement boolean