0
0
Javascriptprogramming~10 mins

Output formatting basics in Javascript - 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 the message to the console.

Javascript
console.log([1]);
Drag options to blanks, or click blank then click option'
Aprint('Hello, world!')
B'Hello, world!'
Cconsole.log('Hello, world!')
DHello, world!
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around the text.
Using print() instead of console.log().
2fill in blank
medium

Complete the code to print the number 42 to the console.

Javascript
console.log([1]);
Drag options to blanks, or click blank then click option'
A'42'
Bnumber(42)
C"42"
D42
Attempts:
3 left
💡 Hint
Common Mistakes
Putting numbers inside quotes makes them strings.
Using number() function which is not needed here.
3fill in blank
hard

Fix the error in the code to print the variable value.

Javascript
let name = 'Alice';
console.log([1]);
Drag options to blanks, or click blank then click option'
A"name"
B'name'
Cname
Dconsole.log(name)
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around the variable name.
Writing console.log inside console.log.
4fill in blank
hard

Fill both blanks to print a greeting with a variable.

Javascript
let user = 'Bob';
console.log('Hello, ' + [1] + [2]);
Drag options to blanks, or click blank then click option'
Auser
B'!'
C'?'
D"!"
Attempts:
3 left
💡 Hint
Common Mistakes
Putting quotes around the variable name.
Using wrong punctuation marks.
5fill in blank
hard

Fill all three blanks to print a formatted message using template literals.

Javascript
let age = 30;
let name = 'Carol';
console.log(`My name is [1] and I am [2] years [3].`);
Drag options to blanks, or click blank then click option'
A${name}
B${age}
Cold
Dyears
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting ${} around variables.
Using quotes instead of backticks.
Missing the word 'old' in the sentence.