0

true ? 'ani': true ? var a=23:'gan'

Why I can't define var in trinary operator

22nd Sep 2021, 8:30 AM
Aniket Ganguly
4 Answers
+ 1
You shouldn't make complicated the code. Ternary operation must be this format: (Condition) ? "if the condition is accepted" : "not accepted" I hope, it helps. Happy coding!
22nd Sep 2021, 8:37 AM
mesarthim
mesarthim - avatar
22nd Sep 2021, 10:32 AM
Simba
Simba - avatar
0
true ?var a=23 : console.log(false) mesarthim why I can't use var a??
22nd Sep 2021, 8:39 AM
Aniket Ganguly
0
Aniket Ganguly If you want to define a variable, you don't have to write "var x" etc. Just write like x = 1. ////// true ? a=23 : a = 1 console.log(a) ///// I thought, you want to do sth like that. Actually, I didn't understand what you mean. Please, explain more.
22nd Sep 2021, 8:46 AM
mesarthim
mesarthim - avatar