0
0
Javascriptprogramming~20 mins

Running JavaScript in browser console - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
JavaScript Console 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 variable scope
What will be printed in the browser console after running this code snippet?
Javascript
let x = 10;
function test() {
  let x = 20;
  console.log(x);
}
test();
console.log(x);
A20\n20
B10\n20
C20\n10
D10\n10
Attempts:
2 left
💡 Hint
Remember that variables declared inside a function have local scope.
Predict Output
intermediate
2:00remaining
Console output of asynchronous code
What is the order of outputs in the browser console after running this code?
Javascript
console.log('Start');
setTimeout(() => console.log('Timeout'), 0);
console.log('End');
AStart\nEnd\nTimeout
BTimeout\nStart\nEnd
CStart\nTimeout\nEnd
DEnd\nStart\nTimeout
Attempts:
2 left
💡 Hint
setTimeout callbacks run after the current call stack is empty.
🔧 Debug
advanced
2:00remaining
Identify the error in console usage
Which option will cause an error when run in the browser console?
Javascript
console.log('Hello');
Aconsole.log('Hello'
Bconsole.log('Hello')
Cconsole.log('Hello');
Dconsole.log('Hello');;
Attempts:
2 left
💡 Hint
Check for missing parentheses or syntax errors.
🧠 Conceptual
advanced
2:00remaining
Console methods for different outputs
Which console method prints a message only if a condition is false?
Aconsole.info()
Bconsole.assert()
Cconsole.warn()
Dconsole.error()
Attempts:
2 left
💡 Hint
This method is used for debugging assumptions.
Predict Output
expert
2:00remaining
Output of console.log with object mutation
What will be the output in the console after running this code?
Javascript
const obj = {a: 1};
console.log(obj);
obj.a = 2;
console.log(obj);
A{a: 1}\n{a: 2}
B{a: 1}\n{a: 1}
CSyntaxError
D{a: 2}\n{a: 2}
Attempts:
2 left
💡 Hint
Objects logged show their state at the time of logging.