2018-09-30 22:01:58 +00:00
|
|
|
---
|
|
|
|
id: cf1111c1c11feddfaeb6bdef
|
|
|
|
title: Divide One Number by Another with JavaScript
|
|
|
|
challengeType: 1
|
2019-02-14 17:24:02 +00:00
|
|
|
videoUrl: 'https://scrimba.com/c/cqkbdAr'
|
2019-07-31 18:32:23 +00:00
|
|
|
forumTopicId: 17566
|
2021-01-13 02:31:00 +00:00
|
|
|
dashedName: divide-one-number-by-another-with-javascript
|
2018-09-30 22:01:58 +00:00
|
|
|
---
|
|
|
|
|
2020-11-27 18:02:05 +00:00
|
|
|
# --description--
|
|
|
|
|
2018-09-30 22:01:58 +00:00
|
|
|
We can also divide one number by another.
|
|
|
|
|
2020-11-27 18:02:05 +00:00
|
|
|
JavaScript uses the `/` symbol for division.
|
|
|
|
|
|
|
|
**Example**
|
2019-05-17 13:20:30 +00:00
|
|
|
|
|
|
|
```js
|
2021-10-25 16:55:58 +00:00
|
|
|
const myVar = 16 / 2;
|
2019-05-17 13:20:30 +00:00
|
|
|
```
|
|
|
|
|
2021-03-03 00:12:12 +00:00
|
|
|
`myVar` now has the value `8`.
|
2020-11-27 18:02:05 +00:00
|
|
|
# --instructions--
|
2018-09-30 22:01:58 +00:00
|
|
|
|
2020-11-27 18:02:05 +00:00
|
|
|
Change the `0` so that the `quotient` is equal to `2`.
|
2018-09-30 22:01:58 +00:00
|
|
|
|
2020-11-27 18:02:05 +00:00
|
|
|
# --hints--
|
2018-09-30 22:01:58 +00:00
|
|
|
|
2020-11-27 18:02:05 +00:00
|
|
|
The variable `quotient` should be equal to 2.
|
2018-09-30 22:01:58 +00:00
|
|
|
|
2020-11-27 18:02:05 +00:00
|
|
|
```js
|
|
|
|
assert(quotient === 2);
|
2018-09-30 22:01:58 +00:00
|
|
|
```
|
|
|
|
|
2020-11-27 18:02:05 +00:00
|
|
|
You should use the `/` operator.
|
2018-09-30 22:01:58 +00:00
|
|
|
|
|
|
|
```js
|
2020-11-27 18:02:05 +00:00
|
|
|
assert(/\d+\s*\/\s*\d+/.test(code));
|
2018-09-30 22:01:58 +00:00
|
|
|
```
|
|
|
|
|
2020-11-27 18:02:05 +00:00
|
|
|
# --seed--
|
2018-09-30 22:01:58 +00:00
|
|
|
|
2020-11-27 18:02:05 +00:00
|
|
|
## --after-user-code--
|
2018-09-30 22:01:58 +00:00
|
|
|
|
|
|
|
```js
|
2018-10-20 18:02:47 +00:00
|
|
|
(function(z){return 'quotient = '+z;})(quotient);
|
2018-09-30 22:01:58 +00:00
|
|
|
```
|
|
|
|
|
2020-11-27 18:02:05 +00:00
|
|
|
## --seed-contents--
|
2018-09-30 22:01:58 +00:00
|
|
|
|
2020-11-27 18:02:05 +00:00
|
|
|
```js
|
2021-10-25 16:55:58 +00:00
|
|
|
const quotient = 66 / 0;
|
2020-11-27 18:02:05 +00:00
|
|
|
```
|
2018-09-30 22:01:58 +00:00
|
|
|
|
2020-11-27 18:02:05 +00:00
|
|
|
# --solutions--
|
2018-09-30 22:01:58 +00:00
|
|
|
|
|
|
|
```js
|
2021-10-25 16:55:58 +00:00
|
|
|
const quotient = 66 / 33;
|
2018-09-30 22:01:58 +00:00
|
|
|
```
|