The modifications made do not run, I do not understand the reason.
Can someone help me understand?
import { updateGold } from "./functions.js";
export const handleKeyPress=(term,state)=>{
return (name, matches, data)=>{
const keyPressed = String.fromCharCode(data.code);
const producers = state.producers;
if(keyPressed.toLowerCase()==='g'){
state.gold +=1;
updateGold(term, state);
}else if (parseInt(keyPressed) >= 0 && parseInt(keyPressed) <= 9) {
const producerId = parseInt(keyPressed);
const selectedProducer = producers.find(producer => producer.id === producerId);
if (selectedProducer && state.gold >= selectedProducer.cost) {
state.gold -= selectedProducer.cost;
selectedProducer.cost *= selectedProducer.growthRate;
selectedProducer.count += 1;
updateGold(term, state);
updateProducers(term, state);
} else if (selectedProducer) {
term(`No tienes suficiente oro para comprar ${selectedProducer.title}.\n`);
}
}
};
}