Your ternary statement is immediately followed by another +
which it doesn't understand how to read. It appears incomplete as "0 + " [...nothing].
To evaluate that statement separately for use in the concatenated string, you need to either evaluate it in another statement, or enclose it in parentheses.
var x=1;
var temp = '{"value":'+ (x == 1 ? 1:0) +'}';
console.log(temp)
Or, you could use ES6 Template Literal string interpolation instead of using +
signs to concatenate the separate parts ... This syntax evaluates your ternary expression inline, then places the result inside the variable placeholder indicated by the dollar sign & curly braces ${[variable]}
. The resulting string prints the value of the interpreted expression.
var temp = `{"value":${(x == 1) ? 1:0}}`