I have the following code in a typescript module:
if (!(wholeWords === true)) {
console.log("Any part", wholeWords);
} else {
console.log("Whole word", wholeWords); }
The "wholeWords" parameter is declared in the argument list for the method as a boolean. (wholeWords: boolean)
In my browser, I see the following:
Any part true
How is this possible?!?
if (wholeWords) {} else {}- actual suggestion - can you logwholeWordsbefore the check? If you setwholeWords = true;right before the logic, does it work?console.log(typeof wholeWords)before that code and see what it returns. I'm making a wild guess thatwholeWordsis actually the string value"true"at runtime, and where you think you've guaranteed thatwholeWordsis abooleanis not actually doing it. Provide more of your code if you want more help.