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
|
||||
function checkScope() {
|
||||
"use strict";
|
||||
var i = "function scope";
|
||||
'use strict';
|
||||
var i = 'function scope';
|
||||
if (true) {
|
||||
i = "block scope";
|
||||
console.log("Block scope i is: ", i);
|
||||
i = 'block scope';
|
||||
console.log('Block scope i is: ', i);
|
||||
}
|
||||
console.log("Function scope i is: ", i);
|
||||
console.log('Function scope i is: ', i);
|
||||
return i;
|
||||
}
|
||||
```
|
||||
@ -69,6 +69,16 @@ function checkScope() {
|
||||
<section id='solution'>
|
||||
|
||||
```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>
|
||||
|
Reference in New Issue
Block a user