0
0
Javascriptprogramming~10 mins

Hoisting with let and const in Javascript - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare a variable with block scope using let.

Javascript
let [1] = 5;
console.log(x);
Drag options to blanks, or click blank then click option'
Avar
Bx
Cconst
Dy
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Using 'var' instead of a variable name.
Using 'const' as a variable name.
Using an undeclared variable name.
2fill in blank
medium

Complete the code to declare a constant variable.

Javascript
const [1] = 10;
console.log(value);
Drag options to blanks, or click blank then click option'
Avalue
Blet
Cvar
Dnum
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Using 'var' or 'let' instead of 'const'.
Using a different variable name than in the console.log.
3fill in blank
hard

Fix the error in accessing a let variable before declaration.

Javascript
console.log([1]);
let a = 3;
Drag options to blanks, or click blank then click option'
Aa
Bb
C3
Dlet
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Using a variable name not declared.
Trying to access the variable before declaration.
4fill in blank
hard

Fill both blanks to create a block-scoped variable and log it.

Javascript
{
  [1] x = 7;
  console.log([2]);
}
Drag options to blanks, or click blank then click option'
Alet
Bvar
Cx
Dy
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Using var which is function-scoped.
Logging a variable name not declared.
5fill in blank
hard

Fill all three blanks to declare a constant and log its value.

Javascript
const [1] = 20;
function show() {
  console.log([2]);
}
show();
console.log([3]);
Drag options to blanks, or click blank then click option'
API
Dradius
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Using different variable names in the blanks.
Using a variable not declared.