3.6 KiB
3.6 KiB
title | localeTitle |
---|---|
Convert Celsius to Fahrenheit | 将摄氏温度转换为华氏温度 |
如果卡住,请记得使用**Read-Search-Ask
** 。尝试配对程序并编写自己的代码
问题说明:
从摄氏温度转换为华氏温度的算法是以摄氏度乘以9/5
的温度加上32
。
您将获得一个可变摄氏度,表示摄氏温度。使用已定义的变量fahrenheit并应用算法为其分配相应的华氏温度。
相关链接
提示:1
看看代码。有一个区域你不应该编辑。从那里开始,问问自己 - 我以前从未见过的那里使用了什么?
现在尝试解决问题
提示:2
请记住**操作顺序,**请查看_链接_部分中的_链接_以获取更多信息。
现在尝试解决问题
扰流警报!
提前解决!
基本代码解决方案
function convertToF(celsius) {
// Only change code below this line
var fahrenheit = (celsius * (9/5)) + 32;
// Only change code above this line
if ( typeof fahrenheit !== 'undefined' ) {
return fahrenheit;
} else {
return 'fahrenheit not defined';
}
}
// Change the inputs below to test your code
convertToF(30);
代码说明:
- 声明fahrenheit变量。
- 在需要时,确保使用括号(
()
)遵循正确的算术运算顺序。
捐款说明:
- 请勿添加与任何现有解决方案类似的解决方案。如果您认为它**相似但更好** ,那么尝试合并(或替换)现有的类似解决方案。
- 添加解决方案的说明。
- 将解决方案分为以下类别之一 - 基本 , 中级和高级 。
- 如果您添加了任何**相关的主要内容,**请仅添加您的用户名。 ( 不要 删除任何现有的用户名 )