Challenge Question

Hello y’all, can someone help me understand why the boolean being set to false isn’t effecting the function that is being carried out according to the execution context?

here is my code,

let friendsAvailable = true;

function makePlans(name) {
 return callFriend(friendsAvailable, name)
  // INSERT CODE HERE
}

function callFriend(bool, name) {
  if (bool = true) {
    return `Plans made with ${name} this weekend`
  } else {
    return `Everyone is busy this weekend`
  }
  // INSERT CODE HERE
}

// Uncomment these to check your work!
console.log(makePlans("Mary")) // should return: "Plans made with Mary this weekend'
friendsAvailable = false
console.log(makePlans("James")
1 Like

= is an assignment operator, not a comparison

you can avoid this by simply not comparing as

if (false) {
   // this doesn't execute
}

if (true) {
   // this execute
}
2 Likes