How can I insert the if
condition inside of ${ }
using jQuery.
$('#inactive_list_body').append(`
<tr>
<td>${value['name']}</td>
<td>${ if(value['status'] == 'false'){
value['identifier']}else{value['status']} }</td>
// ^^^^ Here I need to add IF condition
<td>${value['reason_without_or_inactive']}</td>
</tr>
`);
3
Answers
You could set that variable outside of your append method.
let status = value['status'] ? value['status'] : value['identifier']
Then you can use it as
<td>{status}</td>
You can use the ternary operator
?:
var === 'something' ? 'something' : 'not something'
construction may be used directly inside${ }
block: