2018-10-10 22:03:03 +00:00
|
|
|
---
|
|
|
|
id: bd7993c9c69feddfaeb7bdef
|
2021-03-05 02:55:32 +00:00
|
|
|
title: 两个小数相乘
|
2018-10-10 22:03:03 +00:00
|
|
|
challengeType: 1
|
2020-04-29 10:29:13 +00:00
|
|
|
videoUrl: 'https://scrimba.com/c/ce2GeHq'
|
|
|
|
forumTopicId: 301173
|
2021-01-13 02:31:00 +00:00
|
|
|
dashedName: multiply-two-decimals-with-javascript
|
2018-10-10 22:03:03 +00:00
|
|
|
---
|
|
|
|
|
2020-12-16 07:37:30 +00:00
|
|
|
# --description--
|
2018-10-10 22:03:03 +00:00
|
|
|
|
2021-03-05 02:55:32 +00:00
|
|
|
在 JavaScript 中,你也可以用小数进行计算,就像整数一样。
|
2018-10-10 22:03:03 +00:00
|
|
|
|
2021-03-05 02:55:32 +00:00
|
|
|
把两个小数相乘,并得到它们乘积。
|
2018-10-10 22:03:03 +00:00
|
|
|
|
2020-12-16 07:37:30 +00:00
|
|
|
# --instructions--
|
2018-10-10 22:03:03 +00:00
|
|
|
|
2021-03-05 02:55:32 +00:00
|
|
|
改变 `0.0` 的数值让变量 product 的值等于 `5.0`。
|
2018-10-10 22:03:03 +00:00
|
|
|
|
2020-12-16 07:37:30 +00:00
|
|
|
# --hints--
|
2018-10-10 22:03:03 +00:00
|
|
|
|
2021-03-05 02:55:32 +00:00
|
|
|
变量 `product` 应该等于 `5.0`。
|
2018-10-10 22:03:03 +00:00
|
|
|
|
|
|
|
```js
|
2020-12-16 07:37:30 +00:00
|
|
|
assert(product === 5.0);
|
2018-10-10 22:03:03 +00:00
|
|
|
```
|
|
|
|
|
2021-03-07 16:15:14 +00:00
|
|
|
要使用 `*` 运算符。
|
2018-10-10 22:03:03 +00:00
|
|
|
|
|
|
|
```js
|
2020-12-16 07:37:30 +00:00
|
|
|
assert(/\*/.test(code));
|
2018-10-10 22:03:03 +00:00
|
|
|
```
|
|
|
|
|
2021-01-13 02:31:00 +00:00
|
|
|
# --seed--
|
|
|
|
|
|
|
|
## --after-user-code--
|
|
|
|
|
|
|
|
```js
|
|
|
|
(function(y){return 'product = '+y;})(product);
|
|
|
|
```
|
|
|
|
|
|
|
|
## --seed-contents--
|
|
|
|
|
|
|
|
```js
|
|
|
|
var product = 2.0 * 0.0;
|
|
|
|
```
|
|
|
|
|
2020-12-16 07:37:30 +00:00
|
|
|
# --solutions--
|
2020-04-29 10:29:13 +00:00
|
|
|
|
2021-01-13 02:31:00 +00:00
|
|
|
```js
|
|
|
|
var product = 2.0 * 2.5;
|
|
|
|
```
|