FBISE, NCP & NBF-aligned resources for Classes 9–12
Browse by Class
Browse by Type
Computer Chapter 3 : Topic 3.1
Variables, Data Types and Arrays in JavaScript
1 / 30
A student is creating a dynamic website and wants to store a user's name so that it can be displayed later on different parts of the webpage. Which JavaScript feature should be used?
Reasoning: A variable stores data that can be used and reused throughout a program.
2 / 30
While developing a webpage, a programmer stores the value 25 in a variable. Which JavaScript data type is most suitable for this value?
Reasoning: Numerical values such as 25 belong to the Number data type.
3 / 30
A web application asks users whether they agree to terms and conditions. Which data type is most appropriate for storing the response as either true or false?
Reasoning: Boolean values can only be true or false.
4 / 30
A student stores the value "Pakistan" in a JavaScript variable. Which statement correctly describes this value?
Reasoning: Text enclosed in quotation marks is treated as a String.
5 / 30
A programmer wants to store the marks of five subjects in a single variable-like structure. Which JavaScript feature is most suitable?
Reasoning: Arrays allow multiple related values to be stored together.
6 / 30
Which statement best explains why arrays are useful in dynamic websites and web applications?
Reasoning: Arrays organize collections of related data efficiently.
7 / 30
A variable contains the value "123". How will JavaScript most likely treat this value?
Reasoning: Quotation marks indicate a String even if the content looks numeric.
8 / 30
A student writes the following code: let age = 15;. What is the purpose of age in this statement?
Reasoning: age is the identifier used to store the value.
9 / 30
A website stores the names of registered users in an array. What is the main advantage of this approach?
Reasoning: Arrays are designed to hold multiple values in one structure.
10 / 30
Which of the following values would most likely be stored as a Boolean in a JavaScript program?
Reasoning: false is a Boolean literal in JavaScript.
11 / 30
A programmer creates an array containing the values ["Red", "Blue", "Green"]. What kind of data is being stored?
Reasoning: Each item is text enclosed in quotation marks.
12 / 30
During form validation, a variable stores whether a password is correct. Which data type is most suitable?
Reasoning: The result is usually either true or false.
13 / 30
A student wants to store a user's age and later perform calculations with it. Which data type should be used?
Reasoning: Mathematical operations require numeric values.
14 / 30
A programmer uses an array to store monthly sales data. What characteristic makes an array appropriate for this task?
Reasoning: Arrays can efficiently store collections of related data.
15 / 30
Which of the following JavaScript values represents a Number data type?
Reasoning: A Number is written without quotation marks.
16 / 30
A website displays a welcome message using a user's name stored in a variable. What benefit does this provide?
Reasoning: Variables allow webpages to show customized information.
17 / 30
A programmer accidentally stores a student's roll number as "101" instead of 101. What is the major difference?
Reasoning: Quotation marks convert the value into a String.
18 / 30
Which scenario would most likely require the use of an array rather than a single variable?
Reasoning: Arrays are ideal for managing lists of related values.
19 / 30
A dynamic website updates product prices regularly. Why are variables important in this situation?
Reasoning: Variables allow data to be updated dynamically.
20 / 30
Which of the following sets of values could correctly be stored inside a JavaScript array?
Reasoning: Arrays can store multiple values of various data types.
21 / 30
A programmer stores the value true in a variable named isMember. What information does this variable most likely represent?
Reasoning: Boolean values commonly represent status or conditions.
22 / 30
Which statement best describes a JavaScript variable?
Reasoning: Variables act as containers for data in programs.
23 / 30
A web developer stores the names of seven days in an array. Why is this better than creating seven separate variables?
Reasoning: Arrays organize related data efficiently.
24 / 30
A variable contains the value false. Which statement is true regarding its data type?
Reasoning: false is one of the two Boolean values.
25 / 30
In a JavaScript-based quiz application, which structure is most suitable for storing all quiz questions together?
Reasoning: Arrays can store multiple related items such as quiz questions.
26 / 30
A student wants a variable to hold different values during program execution. Which feature of variables makes this possible?
Reasoning: Variables can be updated as the program runs.
27 / 30
Which of the following examples demonstrates data commonly stored in a String variable on a website?
Reasoning: Names consist of text and are stored as Strings.
28 / 30
A shopping website stores product names in an array. What would happen if a new product needs to be added?
Reasoning: Arrays can be modified to include additional elements.
29 / 30
Which combination correctly matches the value with its data type?
Reasoning: The value true belongs to the Boolean data type.
30 / 30
A student is building a dynamic website using JavaScript. Which combination of concepts is most important for storing, organizing, and manipulating data?
Reasoning: Variables store data, data types define its nature, and arrays organize multiple values efficiently.
Your score is
Restart quiz