0
0
Javascriptprogramming~10 mins

Output using console.log 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 "Hello, world!" to the console.

Javascript
console.[1]("Hello, world!");
Drag options to blanks, or click blank then click option'
Alog
Bwrite
Cprint
Dshow
Attempts:
3 left
💡 Hint
Common Mistakes
Using console.print instead of console.log
Using console.write which is not a valid method
Trying to use console.show which does not exist
2fill in blank
medium

Complete the code to print the value of variable x to the console.

Javascript
let x = 10;
console.[1](x);
Drag options to blanks, or click blank then click option'
Aprint
Bshow
Cwrite
Dlog
Attempts:
3 left
💡 Hint
Common Mistakes
Using console.print(x)
Using console.write(x)
Using console.show(x)
3fill in blank
hard

Fix the error in the code to correctly print "Sum is 15".

Javascript
let a = 7;
let b = 8;
console.[1]("Sum is " + (a + b));
Drag options to blanks, or click blank then click option'
Awrite
Bprint
Clog
Dshow
Attempts:
3 left
💡 Hint
Common Mistakes
Using console.print instead of console.log
Using console.write or console.show which are invalid
4fill in blank
hard

Fill both blanks to print the numbers 1 to 5 using a loop.

Javascript
for(let i = 1; i [1] 5; i[2]) {
  console.log(i);
}
Drag options to blanks, or click blank then click option'
A<=
B<
C++
D--
Attempts:
3 left
💡 Hint
Common Mistakes
Using i < 5 which stops at 4
Using i-- which decreases i causing an infinite loop
5fill in blank
hard

Fill all three blanks to print only even numbers from 2 to 10.

Javascript
for(let num = [1]; num [2] 10; num[3]) {
  if(num % 2 === 0) {
    console.log(num);
  }
}
Drag options to blanks, or click blank then click option'
A1
B<=
C++
D2
Attempts:
3 left
💡 Hint
Common Mistakes
Starting at 1 which includes odd numbers
Using < instead of <= which excludes 10
Using num-- which causes an infinite loop