Basic JavaScript - Use Conditional Logic with If Statements

Tell us what’s happening:
wHATs the answer, and what am i doing wrong
Your code so far

function trueOrFalse(wasThatTrue) {
  // Only change code below this line
  if (thatWasTrue = true) {
    wasThatTrue = "Yes, that was true"
    return wasThatTrue
  }
  wasThatTrue = "No, that was false"
  return wasThatTrue

  // Only change code above this line

}

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36 OPR/94.0.0.0

Challenge: Basic JavaScript - Use Conditional Logic with If Statements

Link to the challenge:

This is setting the variable thatWasTrue to the value true. I’m assuming you meant to use wasThatTrue? Regardless, you want to check if wasThatTrue holds the value true.

Again, you really shouldn’t be changing the variable wasThatTrue. There is no need to.

Since you don’t want to change wasThatTrue then it doesn’t make sense to return it. You can return a plain old string from a function instead.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.