JS
challenger
Home
Intermediate JavaScript
scope
Read an outer variable from a nested function
Read an outer variable from a nested function
A nested function can read variables from its parent function. Inside
inner
, return the
message
variable that was declared in
outer
.
Premium
reset
function greet(name) { return `Hello, ${name}!`; } console.log(greet("Erik"));
JavaScript
Run Code
Console