Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to display a message in the browser console.
Javascript
console.[1]('Hello, JavaScript!');
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using console.print or console.write which do not exist.
Trying to use alert instead of console.log.
✗ Incorrect
The console.log function prints messages to the browser console.
2fill in blank
mediumComplete the code to declare a variable named name with the value 'Alice'.
Javascript
let [1] = 'Alice';
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Putting 'var' or 'let' in the blank instead of the variable name.
Using a number or string instead of a variable name.
✗ Incorrect
The variable name is name. The code declares it with let.
3fill in blank
hardFix the error in the code to correctly add two numbers and store the result.
Javascript
let sum = 5 [1] 3;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using minus or multiplication instead of addition.
Leaving the operator blank.
✗ Incorrect
The plus sign + adds two numbers together.
4fill in blank
hardFill both blanks to create an object with a property and access its value.
Javascript
const person = { [1]: 'Bob' };
console.log(person.[2]); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using different property names for key and access.
Using properties that are not defined.
✗ Incorrect
The object has a property name. Access it with person.name.
5fill in blank
hardFill all three blanks to create a function that returns the square of a number.
Javascript
function [1]([2]) { return [2] [3] [2]; }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using addition instead of multiplication.
Using different variable names inside the function.
✗ Incorrect
The function named square takes num and returns num * num.