1.5 KiB
1.5 KiB
id, challengeType, videoUrl, forumTopicId, title
id | challengeType | videoUrl | forumTopicId | title |
---|---|---|---|---|
56533eb9ac21ba0edf2244b2 | 1 | https://scrimba.com/c/c2QvKT2 | 16659 | 复合赋值之 /= |
Description
/=
操作符是让变量与另一个数相除并赋值。
myVar = myVar / 5;
变量myVar
等于自身除以5
的值。等价于:
myVar /= 5;
Instructions
/=
操作符实现同样的效果。
Tests
tests:
- text: <code>a</code>应该等于<code>4</code>。
testString: assert(a === 4);
- text: <code>b</code>应该等于<code>27</code>。
testString: assert(b === 27);
- text: <code>c</code>应该等于<code>3</code>。
testString: assert(c === 3);
- text: 应该对每个变量使用<code>/=</code>操作符。
testString: assert(code.match(/\/=/g).length === 3);
- text: 不要修改注释上面的代码。
testString: assert(/var a = 48;/.test(code) && /var b = 108;/.test(code) && /var c = 33;/.test(code));
Challenge Seed
var a = 48;
var b = 108;
var c = 33;
// Only modify code below this line
a = a / 12;
b = b / 4;
c = c / 11;
After Test
(function(a,b,c){ return "a = " + a + ", b = " + b + ", c = " + c; })(a,b,c);
Solution
var a = 48;
var b = 108;
var c = 33;
a /= 12;
b /= 4;
c /= 11;