2018-10-10 18:03:03 -04:00
---
id: cf1391c1c11feddfaeb4bdef
title: Create Decimal Numbers with JavaScript
challengeType: 1
2019-08-28 16:26:13 +03:00
videoUrl: https://scrimba.com/c/ca8GEuW
forumTopicId: 16826
2018-10-10 18:03:03 -04:00
localeTitle: Создание десятичных чисел с помощью JavaScript
---
## Description
2019-08-28 16:26:13 +03:00
< section id = 'description' >
Мы также можем хранить десятичные числа в переменных. Десятичные числа иногда называются < dfn > числами с плавающей запятой</ dfn > или < dfn > поплавками</ dfn > . < strong > Заметка</ strong > < br > Н е все реальные числа могут быть точно представлены в < dfn > плавающей точке</ dfn > . Это может привести к ошибкам округления. < a href = "https://en.wikipedia.org/wiki/Floating_point #Accuracy_problems " target = "_blank" > Подробности здесь</ a > .
< / section >
2018-10-10 18:03:03 -04:00
## Instructions
2019-08-28 16:26:13 +03:00
< section id = 'instructions' >
Создайте переменную < code > myDecimal< / code > и дайте ей десятичное значение с дробной частью (например, < code > 5.7< / code > ).
< / section >
2018-10-10 18:03:03 -04:00
## Tests
< section id = 'tests' >
```yml
tests:
2019-08-28 16:26:13 +03:00
- text: < code > myDecimal</ code > should be a number.
testString: assert(typeof myDecimal === "number");
- text: < code > myDecimal</ code > should have a decimal point
testString: assert(myDecimal % 1 != 0);
2018-10-10 18:03:03 -04:00
```
< / section >
## Challenge Seed
< section id = 'challengeSeed' >
< div id = 'js-seed' >
```js
var ourDecimal = 5.7;
// Only change code below this line
```
< / div >
2019-08-28 16:26:13 +03:00
### After Tests
2018-10-10 18:03:03 -04:00
< div id = 'js-teardown' >
```js
2019-08-28 16:26:13 +03:00
(function(){if(typeof myDecimal !== "undefined"){return myDecimal;}})();
2018-10-10 18:03:03 -04:00
```
< / div >
< / section >
## Solution
< section id = 'solution' >
```js
2019-08-28 16:26:13 +03:00
var myDecimal = 9.9;
2018-10-10 18:03:03 -04:00
```
2019-08-28 16:26:13 +03:00
2018-10-10 18:03:03 -04:00
< / section >