0
我正在为一个机械网站制作一个JavaScript闪存卡游戏。因为我想在卡片上添加方程式,所以我需要使用增量(Δ)符号。三角洲标志破解JavaScript代码
一张卡片可能有:“一方的功率方程”和另一方的“P = W /Δt”。如果卡从第一面开始,当按下空格键或按下翻盖按钮时,它将翻转。但是,如果它从第二面开始,即带有Δ符号的那一面,当按下“翻转”按钮或空格键时,它不会翻转。
我曾尝试写作Δ不同的方式:
Δ Δ Δ
没有这些工作的。 我的代码是:
//Copyright Attribution-ShareAlike 4.0 International 2017 Hazel Meehan
//array containing all options
var options = [ //counts from 0
"Joules(J)", "Measure of Work",
"Watts(W)", "Measure of Power",
"Ek", "Kinetic Energy",
"Ep", "Potential Energy",
"Newtons(N)", "Measure of Force",
"Pascals(Pa)", "Pressure",
"ms-1", "Metres per Second",
"ms-2", "Metres per Second Gained",
"10N", "Value of Gravity",
"Weight is a", "Force beginning with W",
"The capacity to do work", "Energy is",
"d = ΔvΔt is the equation for", "The equation for distance",
"W=FΔd is the equation for", "The equation for work",
"P=W/Δt is the equation for", "The equation for power"
];
//initialize variables
var randomNum = 0;
var sideOne = " ";
var sideTwo = " ";
//choose new card using random number
var newCard = function() { //runs on 'next'
var randomNum = Math.floor(Math.random() * options.length);
sideOne = options[randomNum];
if (randomNum % 2 == 0) { //is the number even
sideTwo = options[randomNum + 1];
} else {
sideTwo = options[randomNum - 1];
}
document.getElementById("card").innerHTML = sideOne;
};
//show other side of card
var flip = function() { //runs on 'flip'
if (document.getElementById("card").innerHTML == sideOne) {
document.getElementById("card").innerHTML = sideTwo;
} else {
document.getElementById("card").innerHTML = sideOne;
}
};
//change card on key down
document.onkeydown = function(e) {
e = e || window.event;
if (e.keyCode == '39') { //right arow key
newCard();
} else if (e.keyCode == '32') { //space bar
flip();
}
}
<article>
<h2>Flashcards</h2>
<center><button id="flashButton" onclick="newCard()">Next</button></center>
<br>
<center><button id="card"></button></center>
<br>
<center><button id="flashButton" onclick="flip()">Flip</button></center>
</article>
它在[SO](https://stackoverflow.com)上工作,你应该为你的html添加一个''标签以便看到它们。 –
适合我。你使用的是什么浏览器?任何记录在控制台? – marekful
我可以重现这个错误,当我用'Δ'替换'Δ'时,它会消失。 – ASDFGerte