0
0
Javascriptprogramming~20 mins

What is JavaScript - Practice Questions & Exercises

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
1:00remaining
What is JavaScript used for?

JavaScript is a popular programming language. What is its main use?

ATo style web pages with colors and fonts
BTo create databases for storing data
CTo write server operating systems
DTo add interactivity and dynamic behavior to web pages
Attempts:
2 left
💡 Hint

Think about what happens when you click buttons or see animations on websites.

Predict Output
intermediate
1:30remaining
What is the output of this JavaScript code?

Look at this code and choose the correct output.

Javascript
console.log(typeof []);
A"array"
B"list"
C"object"
D"undefined"
Attempts:
2 left
💡 Hint

In JavaScript, arrays are a type of object.

Predict Output
advanced
1:30remaining
What is the output of this JavaScript code snippet?

What will this code print to the console?

Javascript
console.log(0.1 + 0.2 === 0.3);
Atrue
Bfalse
CTypeError
Dundefined
Attempts:
2 left
💡 Hint

Think about how computers handle decimal numbers.

🧠 Conceptual
advanced
1:00remaining
Which statement about JavaScript is true?

Choose the correct statement about JavaScript.

AJavaScript supports asynchronous programming with promises and async/await.
BJavaScript is a statically typed language.
CJavaScript can only run in web browsers.
DJavaScript code must be compiled before running.
Attempts:
2 left
💡 Hint

Think about how JavaScript handles tasks like fetching data from the internet.

Predict Output
expert
2:00remaining
What is the output of this JavaScript code with closures?

What will this code print to the console?

Javascript
function makeCounter() {
  let count = 0;
  return function() {
    count += 1;
    return count;
  };
}
const counter1 = makeCounter();
const counter2 = makeCounter();
console.log(counter1());
console.log(counter1());
console.log(counter2());
A
1
2
1
B
1
1
1
C
0
1
0
D
2
3
2
Attempts:
2 left
💡 Hint

Each call to makeCounter creates a new independent counter.