2018-09-30 23:01:58 +01:00
|
|
|
---
|
|
|
|
id: 56533eb9ac21ba0edf2244b2
|
|
|
|
title: Compound Assignment With Augmented Division
|
|
|
|
challengeType: 1
|
2019-02-14 12:24:02 -05:00
|
|
|
videoUrl: 'https://scrimba.com/c/c2QvKT2'
|
2019-07-31 11:32:23 -07:00
|
|
|
forumTopicId: 16659
|
2018-09-30 23:01:58 +01:00
|
|
|
---
|
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
# --description--
|
2018-09-30 23:01:58 +01:00
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
The `/=` operator divides a variable by another number.
|
|
|
|
|
|
|
|
`myVar = myVar / 5;`
|
|
|
|
|
|
|
|
Will divide `myVar` by `5`. This can be rewritten as:
|
|
|
|
|
|
|
|
`myVar /= 5;`
|
|
|
|
|
|
|
|
# --instructions--
|
|
|
|
|
|
|
|
Convert the assignments for `a`, `b`, and `c` to use the `/=` operator.
|
|
|
|
|
|
|
|
# --hints--
|
|
|
|
|
|
|
|
`a` should equal `4`.
|
|
|
|
|
|
|
|
```js
|
|
|
|
assert(a === 4);
|
2018-09-30 23:01:58 +01:00
|
|
|
```
|
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
`b` should equal `27`.
|
2018-09-30 23:01:58 +01:00
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
```js
|
|
|
|
assert(b === 27);
|
|
|
|
```
|
2018-09-30 23:01:58 +01:00
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
`c` should equal `3`.
|
2018-09-30 23:01:58 +01:00
|
|
|
|
|
|
|
```js
|
2020-11-27 19:02:05 +01:00
|
|
|
assert(c === 3);
|
|
|
|
```
|
2018-09-30 23:01:58 +01:00
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
You should use the `/=` operator for each variable.
|
|
|
|
|
|
|
|
```js
|
|
|
|
assert(code.match(/\/=/g).length === 3);
|
2018-09-30 23:01:58 +01:00
|
|
|
```
|
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
You should not modify the code above the specified comment.
|
2018-09-30 23:01:58 +01:00
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
```js
|
|
|
|
assert(
|
|
|
|
/var a = 48;/.test(code) &&
|
|
|
|
/var b = 108;/.test(code) &&
|
|
|
|
/var c = 33;/.test(code)
|
|
|
|
);
|
|
|
|
```
|
|
|
|
|
|
|
|
# --seed--
|
2018-09-30 23:01:58 +01:00
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
## --after-user-code--
|
2018-09-30 23:01:58 +01:00
|
|
|
|
|
|
|
```js
|
2018-10-20 21:02:47 +03:00
|
|
|
(function(a,b,c){ return "a = " + a + ", b = " + b + ", c = " + c; })(a,b,c);
|
2018-09-30 23:01:58 +01:00
|
|
|
```
|
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
## --seed-contents--
|
2018-09-30 23:01:58 +01:00
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
```js
|
|
|
|
var a = 48;
|
|
|
|
var b = 108;
|
|
|
|
var c = 33;
|
2018-09-30 23:01:58 +01:00
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
// Only change code below this line
|
|
|
|
a = a / 12;
|
|
|
|
b = b / 4;
|
|
|
|
c = c / 11;
|
|
|
|
```
|
2018-09-30 23:01:58 +01:00
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
# --solutions--
|
2018-09-30 23:01:58 +01:00
|
|
|
|
|
|
|
```js
|
|
|
|
var a = 48;
|
|
|
|
var b = 108;
|
|
|
|
var c = 33;
|
|
|
|
|
|
|
|
a /= 12;
|
|
|
|
b /= 4;
|
|
|
|
c /= 11;
|
|
|
|
```
|