I have a function (Infinite Scrolling) that must receive as parameter the name of the variable that contains integer values (the ones that are initialized), through another variable (categoria) that receives value from an innerText, and at the end it must add the final value to variable that was inside the variable (categoria)
var Refeições = 15;
var Petiscos = 15;
var Porções = 15;
var Bebidas = 10;
function InfiniteScrolling(categoria) {
console.log(`refeições ${Refeições} pestiscos ${Petiscos} porções ${Porções} bebidas ${Bebidas}`)
var pratos = (categoria) => {
if (!(categoria == "Oferta do Dia")) {
for (var i = eval(categoria) + 1; i < eval(categoria) + 16; i++) {
console.log(`${categoria+ i}`)
}
categoria == categoria + 15;
console.log(eval(categoria))
console.log(categoria)
}
}
pratos(categoria)
}
With this I want to know how to use the string value inside the "categoria" variable to reference the variables declared at the beginning, such as "Bebidas "