2018-10-10 18:03:03 -04:00
|
|
|
---
|
|
|
|
id: 56533eb9ac21ba0edf2244b3
|
2020-12-16 00:37:30 -07:00
|
|
|
title: 将摄氏温度转换为华氏温度
|
2018-10-10 18:03:03 -04:00
|
|
|
challengeType: 1
|
|
|
|
videoUrl: ''
|
|
|
|
---
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
# --description--
|
2018-10-10 18:03:03 -04:00
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
从摄氏温度转换为华氏温度的算法是以摄氏度乘以`9/5`,再加上`32` 。您将获得一个参数`celsius`代表着摄氏温度。使用已准备好代表华氏温度的变量`fahrenheit`,将`celsius`摄氏温度变量值兑换成华氏温度值,然后存储在`farenheit`变量里。使用以上提到的算法将摄氏温度转换为华氏温度。不需要过多担心函数和返回语句,因为它们将会在未来的挑战中加以解释。目前,只需使用您已经学过的运算符。
|
2018-10-10 18:03:03 -04:00
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
# --hints--
|
2018-10-10 18:03:03 -04:00
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
`convertToF(0)`应该返回一个数字
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
|
|
```js
|
2020-12-16 00:37:30 -07:00
|
|
|
assert(typeof convertToF(0) === 'number');
|
|
|
|
```
|
2018-10-10 18:03:03 -04:00
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
`convertToF(-30)`应该返回值`-22`
|
2018-10-10 18:03:03 -04:00
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
```js
|
|
|
|
assert(convertToF(-30) === -22);
|
2018-10-10 18:03:03 -04:00
|
|
|
```
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
`convertToF(-10)`应该返回值`14`
|
2018-10-10 18:03:03 -04:00
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
```js
|
|
|
|
assert(convertToF(-10) === 14);
|
|
|
|
```
|
2018-10-10 18:03:03 -04:00
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
`convertToF(0)`应返回值`32`
|
2018-10-10 18:03:03 -04:00
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
```js
|
|
|
|
assert(convertToF(0) === 32);
|
|
|
|
```
|
2018-10-10 18:03:03 -04:00
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
`convertToF(20)`应返回值`68`
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
|
|
```js
|
2020-12-16 00:37:30 -07:00
|
|
|
assert(convertToF(20) === 68);
|
|
|
|
```
|
2019-12-20 23:22:00 +08:00
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
`convertToF(30)`应返回值`86`
|
2019-12-20 23:22:00 +08:00
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
```js
|
|
|
|
assert(convertToF(30) === 86);
|
2018-10-10 18:03:03 -04:00
|
|
|
```
|
2020-08-13 17:24:35 +02:00
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
# --solutions--
|
|
|
|
|