Challenge - 5 Problems
JavaScript Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate2:00remaining
Why is JavaScript popular for web development?
Which of the following reasons best explains why JavaScript is widely used for web development?
Attempts:
2 left
💡 Hint
Think about what makes JavaScript easy to use on any computer with a browser.
✗ Incorrect
JavaScript runs directly inside web browsers, so it doesn't need extra software or plugins. This makes it easy to create interactive websites.
❓ Predict Output
intermediate2:00remaining
Output of JavaScript code using async/await
What will this JavaScript code print to the console?
Javascript
async function greet() { return 'Hello!'; } greet().then(console.log);
Attempts:
2 left
💡 Hint
Remember that async functions return promises, but .then unwraps the value.
✗ Incorrect
The async function returns a promise that resolves to 'Hello!'. Using .then(console.log) prints the resolved value.
❓ Predict Output
advanced2:00remaining
Understanding JavaScript closures
What is the output of this JavaScript code?
Javascript
function makeCounter() { let count = 0; return function() { count += 1; return count; }; } const counter = makeCounter(); console.log(counter()); console.log(counter());
Attempts:
2 left
💡 Hint
Think about how the inner function remembers the variable count.
✗ Incorrect
The inner function forms a closure, keeping count variable alive and increasing it each call.
🔧 Debug
advanced2:00remaining
Identify the error in this JavaScript code
What error will this code cause when run?
Javascript
const obj = { a: 1, b: 2 }; obj = { a: 3, b: 4 };
Attempts:
2 left
💡 Hint
Consider what const means for variables in JavaScript.
✗ Incorrect
Variables declared with const cannot be reassigned, so trying to assign a new object to obj causes a TypeError.
🚀 Application
expert3:00remaining
Why is JavaScript used for both frontend and backend?
Which reason best explains why JavaScript is used on both frontend (browser) and backend (server)?
Attempts:
2 left
💡 Hint
Think about how using one language helps developers build full applications.
✗ Incorrect
JavaScript's consistent syntax and environment allow developers to write code for both frontend and backend, simplifying development.