* feat(tools): add seed/solution restore script * chore(curriculum): remove empty sections' markers * chore(curriculum): add seed + solution to Chinese * chore: remove old formatter * fix: update getChallenges parse translated challenges separately, without reference to the source * chore(curriculum): add dashedName to English * chore(curriculum): add dashedName to Chinese * refactor: remove unused challenge property 'name' * fix: relax dashedName requirement * fix: stray tag Remove stray `pre` tag from challenge file. Signed-off-by: nhcarrigan <nhcarrigan@gmail.com> Co-authored-by: nhcarrigan <nhcarrigan@gmail.com>
56 lines
1.0 KiB
Markdown
56 lines
1.0 KiB
Markdown
---
|
|
id: cf1391c1c11feddfaeb4bdef
|
|
title: 创建一个小数
|
|
challengeType: 1
|
|
videoUrl: 'https://scrimba.com/c/ca8GEuW'
|
|
forumTopicId: 16826
|
|
dashedName: create-decimal-numbers-with-javascript
|
|
---
|
|
|
|
# --description--
|
|
|
|
我们也可以把小数存储到变量中。小数也被称作<dfn>浮点数</dfn> 。
|
|
|
|
**提示**
|
|
不是所有的实数都可以用 <dfn>浮点数</dfn> 来表示。因为可能存在四舍五入的错误,[详情查看](https://en.wikipedia.org/wiki/Floating_point#Accuracy_problems)。
|
|
|
|
# --instructions--
|
|
|
|
创建一个变量`myDecimal`并给它赋值一个浮点数。(例如`5.21`)。
|
|
|
|
# --hints--
|
|
|
|
`myDecimal`应该是一个数字。
|
|
|
|
```js
|
|
assert(typeof myDecimal === 'number');
|
|
```
|
|
|
|
`myDecimal`应该包含小数点。
|
|
|
|
```js
|
|
assert(myDecimal % 1 != 0);
|
|
```
|
|
|
|
# --seed--
|
|
|
|
## --after-user-code--
|
|
|
|
```js
|
|
(function(){if(typeof myDecimal !== "undefined"){return myDecimal;}})();
|
|
```
|
|
|
|
## --seed-contents--
|
|
|
|
```js
|
|
var ourDecimal = 5.7;
|
|
|
|
// Only change code below this line
|
|
```
|
|
|
|
# --solutions--
|
|
|
|
```js
|
|
var myDecimal = 9.9;
|
|
```
|