0
0
Javascriptprogramming~10 mins

Writing first JavaScript program - Interactive Code Practice

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

Complete the code to print 'Hello, world!' to the console.

Javascript
console.[1]('Hello, world!');
Drag options to blanks, or click blank then click option'
Awrite
Bshow
Cprint
Dlog
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.
2fill in blank
medium

Complete 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'
Agreeting
Bmessage
Ctext
Dhello
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different variable name than 'greeting' does not meet the task requirement.
3fill in blank
hard

Fix 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'
A+
B-
C*
D/
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-' subtracts numbers instead of adding.
Using '*' or '/' performs multiplication or division, not addition.
4fill in blank
hard

Fill 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'
Agreet
Bhello
Clog
Dprint
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'hello' as function name instead of 'greet'.
Using 'print' instead of 'log' causes an error.
5fill in blank
hard

Fill 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'
AsayHello
Breturn
Dconsole.log
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.