53 lines
914 B
Markdown
53 lines
914 B
Markdown
![]() |
---
|
||
|
id: bd7993c9c69feddfaeb7bdef
|
||
|
title: JavaScript で 2 つの小数を掛け合わせる
|
||
|
challengeType: 1
|
||
|
videoUrl: 'https://scrimba.com/c/ce2GeHq'
|
||
|
forumTopicId: 301173
|
||
|
dashedName: multiply-two-decimals-with-javascript
|
||
|
---
|
||
|
|
||
|
# --description--
|
||
|
|
||
|
JavaScript では小数の計算も整数と同様に行えます。
|
||
|
|
||
|
2 つの小数を掛け合わせて積を計算してみましょう。
|
||
|
|
||
|
# --instructions--
|
||
|
|
||
|
`0.0` を変更して、積が `5.0` と等しくなるようにしてください。
|
||
|
|
||
|
# --hints--
|
||
|
|
||
|
変数 `product` は `5.0` に等しくなる必要があります。
|
||
|
|
||
|
```js
|
||
|
assert(product === 5.0);
|
||
|
```
|
||
|
|
||
|
`*` 演算子を使用する必要があります。
|
||
|
|
||
|
```js
|
||
|
assert(/\*/.test(code));
|
||
|
```
|
||
|
|
||
|
# --seed--
|
||
|
|
||
|
## --after-user-code--
|
||
|
|
||
|
```js
|
||
|
(function(y){return 'product = '+y;})(product);
|
||
|
```
|
||
|
|
||
|
## --seed-contents--
|
||
|
|
||
|
```js
|
||
|
const product = 2.0 * 0.0;
|
||
|
```
|
||
|
|
||
|
# --solutions--
|
||
|
|
||
|
```js
|
||
|
const product = 2.0 * 2.5;
|
||
|
```
|