Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to define a function named greet.
Javascript
function [1]() { console.log('Hello!'); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
π‘ Hint
Common Mistakes
Using a different function name than asked.
β Incorrect
The function name should be greet as asked.
2fill in blank
mediumComplete the code to call the function greet.
Javascript
[1](); Drag options to blanks, or click blank then click option'
Attempts:
3 left
π‘ Hint
Common Mistakes
Calling a function name that was not defined.
β Incorrect
To call the function named greet, write greet().
3fill in blank
hardFix the error in the function call to greet.
Javascript
greet[1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
π‘ Hint
Common Mistakes
Using braces or brackets instead of parentheses.
β Incorrect
Functions are called with parentheses (). Missing them causes an error.
4fill in blank
hardFill 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'
Attempts:
3 left
π‘ Hint
Common Mistakes
Using subtraction or multiplication instead of addition.
Adding extra characters after the second variable.
β Incorrect
The operator to add two numbers is +. No extra character is needed after b.
5fill in blank
hardFill 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'
Attempts:
3 left
π‘ Hint
Common Mistakes
Using different names for the parameter and inside the message.
Using a different function name than asked.
β Incorrect
The function name is greet, the parameter is name, and the same parameter is used inside the message.