scrimba
Advanced JavaScript I
JS 87 - Exercise: Sum with closures
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

JS 87 - Exercise: Sum with closures
AboutCommentsNotes
JS 87 - Exercise: Sum with closures
Expand for more info
index.js
run
preview
console
// https://javascript.info/closure
// Function in if
let phrase = "Hello";

if (true) {
let user = "John";

function sayHi() {
console.log(`${phrase}, ${user}`);
}
}

sayHi();
Console
ReferenceError: sayHi is not defined (/index.js:15)
,
index.html
-1:02