Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

JavaScript boolean help

Pavel

Well-Known Coder
Hi,

please see
Code:
const money = 0;
if(money) {
    console.log ("dont spend it all");
} else
    console.log("you should get a job");

i need help here...

i understand JS will try ro coerce any value into a boolean

if its not a boolean JS will try to convert it to a boolean

where do truthy and falsey apply here?

having trouble with this cocept,

i ask for help
 
First, console.log (... with a space won't work.
I'm pretty sure it will actually work, however I do recommend being consistent and not putting a space there.
Same with the else statement not having curly brackets, although not syntactically wrong, I would recommend always using it.
 

Buy us a coffee!

Back
Top Bottom