Advertisements
I thought this would be something simple to do, but I don’t think it’s possible, why is that?
This is what I’m trying to do.
console.log("hello") ? bool : "";
This gives me an error: Expected an assignment or function call and instead saw an expression. Not sure exactly what that means.
>Solution :
Yes. you have to evaluate the expression at runtime.
Do I like this.
const someBool = true;
console.log(someBool?'hello':'goodbye');