Javascript 单击按钮时如何更改常量值?

Javascript 单击按钮时如何更改常量值?,javascript,arrays,function,event-listener,Javascript,Arrays,Function,Event Listener,有人能帮我更换console.log行吗?它可以帮助我根据单击的按钮更改player.choice值吗 const播放器={ currentChoice:空 } 常数计算机={ currentChoice:空 } const choices=[“青金石”、“纸莎草”、“手术刀”]; document.querySelector(“#Lapis”).onclick=setLapis document.querySelector(“#Papyrus”).onclick=setPapyrus doc

有人能帮我更换console.log行吗?它可以帮助我根据单击的按钮更改player.choice值吗

const播放器={
currentChoice:空
}
常数计算机={
currentChoice:空
}
const choices=[“青金石”、“纸莎草”、“手术刀”];
document.querySelector(“#Lapis”).onclick=setLapis
document.querySelector(“#Papyrus”).onclick=setPapyrus
document.querySelector(“#手术刀”).onclick=setScalpellus;
函数setLapis(){
控制台日志(“LAPI”);
}
函数setPapyrus(){
控制台日志(“纸草”);
}
函数setScalpellus(){
控制台日志(“手术刀”);
}
player.currentChoice=选项[0]
Lapis
纸莎草
手术刀
const播放器={
currentChoice:空
}
常数计算机={
currentChoice:空
}
const choices=[“青金石”、“纸莎草”、“手术刀”];
document.querySelector(“#Lapis”).onclick=setLapis
document.querySelector(“#Papyrus”).onclick=setPapyrus
document.querySelector(“#手术刀”).onclick=setScalpellus;
函数setLapis(){
player.currentChoice=选项[0];
console.log(player.currentChoice);
}
函数setPapyrus(){
player.currentChoice=选项[1];
console.log(player.currentChoice);
}
函数setScalpellus(){
player.currentChoice=选项[2];
console.log(player.currentChoice);
}
Lapis
纸莎草

手术刀
player.currentChoice=“Lapis”;这似乎对我不起作用