0
0
Javascriptprogramming~10 mins

Function hoisting behavior 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 call the function before its declaration.

Javascript
console.log([1]());
function greet() { return 'Hello!'; }
Drag options to blanks, or click blank then click option'
Agreet
BsayHello
Chello
Dgreeting
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Using a variable name that is not declared as a function.
Trying to call a function expression before its assignment.
2fill in blank
medium

Complete the code to assign a function expression and call it.

Javascript
const sayHi = [1]() { return 'Hi!'; };
console.log(sayHi());
Drag options to blanks, or click blank then click option'
Afun
Bfunc
Cfunction
Ddef
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Using incorrect keywords like 'func' or 'def' which are not valid in JavaScript.
Omitting the function keyword entirely.
3fill in blank
hard

Complete the code to call the function expression correctly.

Javascript
const greet = function() { return 'Hello!'; };
console.log([1]());
Drag options to blanks, or click blank then click option'
AsayHello
Bgreeting
Chello
Dgreet
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Calling the function expression before it is assigned.
Using a different variable name than the one assigned.
4fill in blank
hard

Fill both blanks to create a function expression and call it.

Javascript
const add = [1](a, b) [2] a + b;
console.log(add(2, 3));
Drag options to blanks, or click blank then click option'
A() =>
B=>
C{ return
Dfunction
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Using arrow function syntax incorrectly.
Omitting the return statement inside braces.
5fill in blank
hard

Fill all three blanks to create a function expression and call it.

Javascript
const multiply = [1](x, y) [2] x * y;
console.log([3](4, 5));
Drag options to blanks, or click blank then click option'
Afunction
B{ return
Cmultiply
D() =>
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Using arrow function syntax incorrectly.
Calling the function with a wrong name.