0
0
Javascriptprogramming~20 mins

Why JavaScript is widely used - Challenge Your Understanding

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
JavaScript Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Why is JavaScript popular for web development?
Which of the following reasons best explains why JavaScript is widely used for web development?
AIt runs only on the server side, making websites faster.
BIt can run directly in web browsers without needing extra software.
CIt is only used for styling web pages, like colors and fonts.
DIt requires special plugins to work on most browsers.
Attempts:
2 left
💡 Hint
Think about what makes JavaScript easy to use on any computer with a browser.
Predict Output
intermediate
2: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);
AHello!
BPromise { 'Hello!' }
Cundefined
DError: greet is not a function
Attempts:
2 left
💡 Hint
Remember that async functions return promises, but .then unwraps the value.
Predict Output
advanced
2: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());
A1\n2
B1\n1
Cundefined\nundefined
D0\n1
Attempts:
2 left
💡 Hint
Think about how the inner function remembers the variable count.
🔧 Debug
advanced
2: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 };
AReferenceError: obj is not defined
BSyntaxError: Unexpected token =
CTypeError: Assignment to constant variable.
DNo error, code runs fine
Attempts:
2 left
💡 Hint
Consider what const means for variables in JavaScript.
🚀 Application
expert
3: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)?
AJavaScript can only run in browsers, so backend use is impossible.
BJavaScript is the fastest language for backend servers.
CJavaScript requires different versions for frontend and backend.
DJavaScript syntax is the same everywhere, so developers can use one language for both sides.
Attempts:
2 left
💡 Hint
Think about how using one language helps developers build full applications.