-1
所以我正在做一些練習的java腳本類,我有我的if語句的問題我創建的按鈕來計算攝氏不工作,但如果我刪除我的if語句的代碼運行。JavaScript新語句如果語句故障
<html>
<head>
<title>Template</title>
</head>
<body>
<h3>Lab 2</h3>`enter code here`
<p><input type="button" id="myButton1" value="Click here to enter
temperature." onclick="getTemp()" /></p>
<script type="text/javascript">
function getTemp()
{
var enterTemp = parseInt(prompt("Enter temperature"," "));
var tempType = prompt("Was that temperature in Celsius -'C' or fahrenheit - 'F'?"," ");
if(tempType == "C")
{
var finalTemp = enterTemp * 1.8 + 32;
document.write("<p> in Celsius"+finalTemp"</p>");
}
else
{
var finalTemp = enterTemp/1.8 - 32;
document.write("<p> in Fahrenheit"+finalTemp"</p>");
}
}
</script>
</body>
</html>
Java!= JavaScript –
歡迎來到Stack Overflow!看起來你正在尋求作業幫助。雖然我們本身沒有任何問題,但請觀察這些[應做和不應該](http://meta.stackoverflow.com/questions/334822/how-do-i-ask-and-answer-homework-questions/338845#338845),並相應地編輯您的問題。 –