1.5 KiB
1.5 KiB
id, challengeType, forumTopicId, title
id | challengeType | forumTopicId | title |
---|---|---|---|
587d7b83367417b2b2512b33 | 1 | 18372 | 使用控制台检查变量值 |
Description
console.log()
方法可能是最有用的调试工具,它可以将括号中的内容输出到控制台,将它放在代码中的关键点可以显示变量在当时的值。在查看输出之前,最好先想清楚输出应该是什么。在代码的合适位置打点来查看变量状态有助于定位问题。
下面是输出 'Hello world!' 到控制台的示例:
console.log('Hello world!');
Instructions
console.log()
方法在代码中注明的地方输出变量a
的值。
Tests
tests:
- text: 你应使用<code>console.log()</code>来检查变量<code>a</code>的值。
testString: assert(code.match(/console\.log\(a\)/g));
Challenge Seed
let a = 5;
let b = 1;
a++;
// Add your code below this line
let sumAB = a + b;
console.log(sumAB);
Solution
var a = 5; console.log(a);