我不知道如何在模板字符串中实现大于公式以返回布尔值(参见代码)。
const age = 47; // simplified for question
let html;
html = `<ul>
<li>Alcohol allowed?: ${if (age > 20) {return 'true'} else {return 'false'}}</li>
</ul>`;
document.getElementById("replace").innerHTML = html;
<html>
<body>
<ul>
<li>Alcohol allowed?: true/false</li>
</ul>
</body>
</html>