There's a magic way with JS that kinda breaks your brain but it works
var numValue = 6
var finalValue = `Hello X${numValue > 5 && `, ${numValue} is your promo code` || ''}`
console.log(finalValue)
// Hello X, 6 is your promo code
Where if the numValue=5
const numValue = 5
const finalValue = `Hello X${numValue > 5 && `, ${numValue} is your promo code` || ''}`
console.log(finalValue)
// Hello X
So in case numValue > 5
is true
the returned value be ${numValue} is your promo code
but if it's false then we need to add the || ''
to return an empty string or you will have false
in your string.
It's not a clean solution but it's a solution to consider
But for your own benefit and others when reading the code the conventional ways are better
Example:
const n = 6
let fv = "Hello X"
fv += n > 5 ? `, ${n} is your promo code` : ''
console.log(fv)
// Hello X, 6 is your promo code
Or the other ways suggested above altho some of those examples look like an overkill
GLHF :)