在我回答这个问题之前,我只想说一件事。我是一个对编程感兴趣的年轻人,所以如果答案超级简单,请不要对我发火。PS。对不起我的英语不好:P
事情就是这样。我正在尝试在 JavaScript 中制作华氏温度和摄氏温度之间的转换器。我根本无法理解我enter code here
做错了什么。我的代码;
//Line 2 asks the user what he/she want to convert. Either celcius to farenheit, or farenheit to celcius
var userChoice = prompt("For converting farenheit to celcius, type FtoC. For converting celcius to farenheit, type CtoF");
//Defines a function to calculate the math
var celciustofarenheit = function (userChoice) {
if (userChoice === "CtoF")
var CtoFchoice = prompt("Whats the degree you want to convert?")
var result1 = CtoFchoice * 9 / 5 + 32;
console.log(CtoFchoice, "is", result1, "in farenheit!")
}
if (userChoice === "FtoC") {
var FtoCchoice = prompt("Whats the number you want to convert?")
var result2 = FtoCchoice - 32 * 5 / 9;
console.log(FtoCchoice, "is", result2, "in celcius!")
}
};
请告诉我我做错了什么,而不仅仅是粘贴正确的代码!:)