freeCodeCamp/curriculum/challenges/chinese/02-javascript-algorithms-an.../basic-javascript/create-decimal-numbers-with...

1.4 KiB

id title challengeType videoUrl localeTitle
cf1391c1c11feddfaeb4bdef Create Decimal Numbers with JavaScript 1 使用JavaScript创建十进制数

Description

我们也可以在变量中存储十进制数。十进制数有时称为浮点数浮点数注意
并非所有实数都可以准确地以浮点表示。这可能导致舍入错误。 细节在这里

Instructions

创建一个变量myDecimal并给它一个带小数部分的十进制值(例如5.7 )。

Tests

tests:
  - text: <code>myDecimal</code>应该是一个数字。
    testString: 'assert(typeof myDecimal === "number", "<code>myDecimal</code> should be a number.");'
  - text: <code>myDecimal</code>应该有一个小数点
    testString: 'assert(myDecimal % 1 != 0, "<code>myDecimal</code> should have a decimal point"); '

Challenge Seed

var ourDecimal = 5.7;

// Only change code below this line

After Test

console.info('after the test');

Solution

// solution required