Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to print 'Hello, world!' to the console.
Javascript
console.[1]('Hello, world!');
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'print' instead of 'log' causes an error because 'print' is not a console method.
Using 'write' or 'show' are not valid console methods.
✗ Incorrect
In JavaScript, console.log() is used to print messages to the console.
2fill in blank
mediumComplete the code to declare a variable named greeting with the value 'Hello'.
Javascript
let [1] = 'Hello';
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different variable name than 'greeting' does not meet the task requirement.
✗ Incorrect
The variable name should be greeting as specified.
3fill in blank
hardFix the error in the code to correctly display the sum of 5 and 3.
Javascript
console.log(5 [1] 3);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-' subtracts numbers instead of adding.
Using '*' or '/' performs multiplication or division, not addition.
✗ Incorrect
The plus sign + adds two numbers together in JavaScript.
4fill in blank
hardFill both blanks to create a function named greet that prints 'Hi!' when called.
Javascript
function [1]() { console.[2]('Hi!'); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'hello' as function name instead of 'greet'.
Using 'print' instead of 'log' causes an error.
✗ Incorrect
The function name should be greet and console.log prints the message.
5fill in blank
hardFill both blanks to create an arrow function named sayHello that returns 'Hello!'.
Javascript
const [1] = () => { [2] 'Hello!'; };
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'console.log' instead of 'return' does not return the value.
Adding extra characters after the string causes syntax errors.
✗ Incorrect
The arrow function is named sayHello, uses return to send back the string, and no extra symbols after the string.