这是挑战:
创建一个接受字符串的函数 makePlans。这个字符串应该是一个名字。函数 makePlans 应该调用函数 callFriend 并返回结果。callFriend 接受一个布尔值和一个字符串。将friendsAvailable 变量和名称传递给callFriend。
创建一个接受布尔值和字符串的函数 callFriend。如果布尔值为真,则 callFriend 应返回字符串“本周末使用 NAME 制定的计划”。否则它应该返回“这个周末每个人都很忙”。>
这是我写的:
let friendsAvailable = true;
function makePlans(name) {
return callFriend(friendsAvailable, name);
}
function callFriend(bool, name) {
if (bool = true) {
return 'Plans made with ' + (name) + ' this weekend'
} else {
'Everyone is busy this weekend'
}
}
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."