Forum Moderators: open
var code = (x=5)?"width=\""x:"width=\""(x-1);
For x=5, I want to print: width="5" Else print: width="4"
var code = 'width="'+ (x==5? x:x-1) + '"';
But that doesn't quite match this...
This does:
var code = 'width="'+ (x==5? 5:4) + '"';
var code = "width = "+ (x==5? x : 4);
isn't closer to what is desired. I'm not sure but what the extra quotes were attempting number/string conversion, unnecessarily.