Files
freeCodeCamp/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-algorithm-scripting/convert-celsius-to-fahrenheit.md
Nicholas Carrigan (he/him) aff0ea700d chore(i8n,learn): processed translations (#41350)
* chore(i8n,learn): processed translations

* fix: restore deleted test

* fix: revert casing change

Co-authored-by: Crowdin Bot <support+bot@crowdin.com>
2021-03-04 10:49:46 -07:00

1.2 KiB

id, title, challengeType, forumTopicId, dashedName
id title challengeType forumTopicId dashedName
56533eb9ac21ba0edf2244b3 将摄氏度转换为华氏度 1 16806 convert-celsius-to-fahrenheit

--description--

将摄氏度转换为华氏度的计算方式为:摄氏度乘以 9/5 然后加上 32

输入参数 celsius 代表一个摄氏度的温度。 使用已定义的变量 fahrenheit,并赋值为相应的华氏度的温度值。 根据上述转换公式来进行转换。

--hints--

convertToF(0) 应返回一个数字。

assert(typeof convertToF(0) === 'number');

convertToF(-30) 应返回 -22

assert(convertToF(-30) === -22);

convertToF(-10) 应返回 14

assert(convertToF(-10) === 14);

convertToF(0) 应返回 32

assert(convertToF(0) === 32);

convertToF(20) 应返回 68

assert(convertToF(20) === 68);

convertToF(30) 应返回 86

assert(convertToF(30) === 86);

--seed--

--seed-contents--

function convertToF(celsius) {
  let fahrenheit;
  return fahrenheit;
}

convertToF(30);

--solutions--

function convertToF(celsius) {
  let fahrenheit = celsius * 9/5 + 32;

  return fahrenheit;
}

convertToF(30);