I have a simple ajax request returning some data and then inserting into a template literal. I was wondering if it it possible to insert an \'if\' statement inside the template?
To use a variable while using the ternary operator, use a nested template literal like this:
let var1 = 6 let var2 = 8 console.log(`${ `${var1 > var2 ? var1 + ` (var1) `: var2 + ` (var2) `}` } is greater`)