freeCodeCamp/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/subtract-one-number-from-another-with-javascript.chinese.md

1.2 KiB

id, title, challengeType, videoUrl, forumTopicId, localeTitle
id title challengeType videoUrl forumTopicId localeTitle
cf1111c1c11feddfaeb4bdef Subtract One Number from Another with JavaScript 1 https://scrimba.com/c/cP3yQtk 18314 减法运算

Description

我们也可以在 JavaScript 中进行减法运算。 JavaScript 中使用-来做减法运算。

示例

myVar = 12 - 6; // assigned 6

Instructions

改变数字0让变量 difference 的值为12

Tests

tests:
  - text: 要使<code>difference</code>的值等于 12。
    testString: assert(difference === 12);
  - text: 只用 45 减去一个数。
    testString: assert(/var\s*difference\s*=\s*45\s*-\s*[0-9]*;(?!\s*[a-zA-Z0-9]+)/.test(code));

Challenge Seed

var difference = 45 - 0;


After Test

(function(z){return 'difference = '+z;})(difference);

Solution

var difference = 45 - 33;