Files
freeCodeCamp/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/create-decimal-numbers-with-javascript.md
2022-09-07 14:34:53 +02:00

1.2 KiB

id, title, challengeType, videoUrl, forumTopicId, dashedName
id title challengeType videoUrl forumTopicId dashedName
cf1391c1c11feddfaeb4bdef 创建一个小数 1 https://scrimba.com/c/ca8GEuW 16826 create-decimal-numbers-with-javascript

--description--

我们也可以把小数存储到变量中。 小数有时候也被称作浮点数或者 floats

注意: 当你计算数字时,它们是以有限的精确度计算的。 使用浮点数的运算可能产生不同于预期结果的结果。 如果你生成了一个非预期的结果,请在 freeCodeCamp 论坛上创建一个话题进行说明。

--instructions--

创建一个变量 myDecimal,并给它赋值一个浮点数(例如 5.7)。

--hints--

myDecimal 应该是一个数字。

assert(typeof myDecimal === 'number');

myDecimal 应该包含小数点。

assert(myDecimal % 1 != 0);

--seed--

--after-user-code--

(function(){if(typeof myDecimal !== "undefined"){return myDecimal;}})();

--seed-contents--

const ourDecimal = 5.7;

// Only change code below this line

--solutions--

const myDecimal = 9.9;