0
0
Javascriptprogramming~10 mins

Why functions are needed in Javascript - Test Your Understanding

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

Complete the code to define a function named greet.

Javascript
function [1]() {
  console.log('Hello!');
}
Drag options to blanks, or click blank then click option'
AsayHello
Bgreet
Chello
Dwelcome
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Using a different function name than asked.
2fill in blank
medium

Complete the code to call the function greet.

Javascript
[1]();
Drag options to blanks, or click blank then click option'
Agreet
Bwelcome
Chello
DsayHello
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Calling a function name that was not defined.
3fill in blank
hard

Fix the error in the function call to greet.

Javascript
greet[1];
Drag options to blanks, or click blank then click option'
A()
B{}
C[]
D;
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Using braces or brackets instead of parentheses.
4fill in blank
hard

Fill both blanks to create a function that adds two numbers and returns the result.

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

Fill all three blanks to create a function that takes a name and prints a greeting.

Javascript
function [1]([2]) {
  console.log('Hello, ' + [3] + '!');
}
Drag options to blanks, or click blank then click option'
Agreet
Bname
DsayHello
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Using different names for the parameter and inside the message.
Using a different function name than asked.