In JavaScript, a backtick† seems to work the same as a single quote. For instance, I can use a backtick to define a string like this:
var s
The good part is we can make basic maths directly:
let nuts = 7
more.innerHTML = `
You collected ${nuts} nuts so far!
Double it, get ${nuts + nuts} nuts!!
`
It became really useful in a factory function:
function nuts(it){
return `
You have ${it} nuts!
Cosinus of your nuts: ${Math.cos(it)}
Triple nuts: ${3 * it}
Your nuts encoded in BASE64:
${btoa(it)}
`
}
nut.oninput = (function(){
out.innerHTML = nuts(nut.value)
})
NUTS CALCULATOR