Say you have the variable, the reason I ask if it is possible to use a variable is if I were to use an input to dynamically change the var:
var str = "pineapples"
var cost = {
pineapples: "free",
apples: "£1"
}
how would it be possible to use it as an object name
document.getElementById("result").innerHTML=cost.??