Solution compare-scopes-of-the-var-and-let-keywords.english.md (#18756)
* Update compare-scopes-of-the-var-and-let-keywords.english.md * Improved JavaScript style
This commit is contained in:
committed by
Todd Chaffee
parent
7d0212dfb8
commit
1e3804889e
@ -48,13 +48,13 @@ tests:
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
function checkScope() {
|
function checkScope() {
|
||||||
"use strict";
|
'use strict';
|
||||||
var i = "function scope";
|
var i = 'function scope';
|
||||||
if (true) {
|
if (true) {
|
||||||
i = "block scope";
|
i = 'block scope';
|
||||||
console.log("Block scope i is: ", i);
|
console.log('Block scope i is: ', i);
|
||||||
}
|
}
|
||||||
console.log("Function scope i is: ", i);
|
console.log('Function scope i is: ', i);
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@ -69,6 +69,16 @@ function checkScope() {
|
|||||||
<section id='solution'>
|
<section id='solution'>
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// solution required
|
function checkScope() {
|
||||||
|
'use strict';
|
||||||
|
let i = 'function scope';
|
||||||
|
if (true) {
|
||||||
|
let i = 'block scope';
|
||||||
|
console.log('Block scope i is: ', i);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('Function scope i is: ', i);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
```
|
```
|
||||||
</section>
|
</section>
|
||||||
|
Reference in New Issue
Block a user