0
0
Javascriptprogramming~20 mins

Output using console.log in Javascript - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Console Log Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of console.log with template literals
What is the output of this code?
const name = "Alice";
const age = 30;
console.log(`Name: ${name}, Age: ${age}`);
Javascript
const name = "Alice";
const age = 30;
console.log(`Name: ${name}, Age: ${age}`);
AName: Alice Age: 30
BName: name, Age: age
CName: ${name}, Age: ${age}
DName: Alice, Age: 30
Attempts:
2 left
💡 Hint
Look how template literals use ${} to insert variables inside backticks.
Predict Output
intermediate
2:00remaining
Output of console.log with multiple arguments
What will this code print?
console.log("Hello", "World", 2024);
Javascript
console.log("Hello", "World", 2024);
AHello World 2024
BHello, World, 2024
CHelloWorld2024
D"Hello World 2024"
Attempts:
2 left
💡 Hint
console.log prints each argument separated by spaces.
Predict Output
advanced
2:00remaining
Output of console.log with undefined variable
What happens when you run this code?
let x;
console.log(x);
Javascript
let x;
console.log(x);
A0
Bnull
Cundefined
DReferenceError
Attempts:
2 left
💡 Hint
Variables declared but not assigned have a special value.
Predict Output
advanced
2:00remaining
Output of console.log with object and array
What will this code print?
const obj = {a: 1, b: 2};
const arr = [3, 4];
console.log(obj, arr);
Javascript
const obj = {a: 1, b: 2};
const arr = [3, 4];
console.log(obj, arr);
A{ a: 1, b: 2 } [ 3, 4 ]
B[object Object] [3,4]
C{a:1,b:2},[3,4]
Da:1,b:2 3,4
Attempts:
2 left
💡 Hint
console.log prints objects and arrays in readable form separated by spaces.
🧠 Conceptual
expert
3:00remaining
Behavior of console.log with asynchronous code
What is the output order of this code?
console.log('Start');
setTimeout(() => console.log('Timeout'), 0);
console.log('End');
Javascript
console.log('Start');
setTimeout(() => console.log('Timeout'), 0);
console.log('End');
AEnd\nStart\nTimeout
BStart\nEnd\nTimeout
CTimeout\nStart\nEnd
DStart\nTimeout\nEnd
Attempts:
2 left
💡 Hint
setTimeout with 0 delay runs after current code finishes.