0
0
Javascriptprogramming~10 mins

Function execution flow 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 greet.

Javascript
function greet() {
  console.log('Hello!');
}

greet[1];
Drag options to blanks, or click blank then click option'
A[]
B{}
C()
D;
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Forgetting the parentheses and just writing the function name.
Using curly braces or square brackets instead of parentheses.
2fill in blank
medium

Complete the code to return the sum of two numbers inside the function.

Javascript
function add(a, b) {
  return a [1] b;
}
Drag options to blanks, or click blank then click option'
A/
B-
C*
D+
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Using subtraction - instead of addition.
Using multiplication or division operators by mistake.
3fill in blank
hard

Fix the error in the function call to correctly pass the argument.

Javascript
function sayName(name) {
  console.log('Name:', name);
}

sayName[1];
Drag options to blanks, or click blank then click option'
A'John'
B('John')
C(John)
DJohn
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Passing the string without quotes, causing a reference error.
Not using parentheses to call the function.
4fill in blank
hard

Fill both blanks to create a function that returns the square of a number.

Javascript
function square(num) {
  return num [1] [2];
}
Drag options to blanks, or click blank then click option'
A**
B*
C2
Dnum
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Using multiplication * but forgetting to multiply by the number itself.
Using the wrong operator or missing the exponent.
5fill in blank
hard

Fill the blanks to create a function that filters numbers greater than 10 from an array.

Javascript
function filterGreater(arr) {
  return arr.filter(num => num [1] [2]);
}
Drag options to blanks, or click blank then click option'
A>
B10
C==
D<
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Using equality == instead of greater than.
Using less than < instead of greater than.