0

JavaScript Variables and Data Types

Description: This quiz is designed to assess your understanding of JavaScript variables and data types. It covers various concepts such as variable declaration, data types, and operators.
Number of Questions: 15
Created by:
Tags: javascript variables data types operators
Attempted 0/15 Correct 0 Score 0

In JavaScript, variables are declared using which keyword?

  1. var

  2. let

  3. const

  4. All of the above


Correct Option: D
Explanation:

In JavaScript, variables can be declared using the keywords var, let, or const. var is used for variables that can be reassigned, let is used for variables that can be reassigned within a specific scope, and const is used for variables that cannot be reassigned.

What is the data type of a variable that can store whole numbers?

  1. Number

  2. String

  3. Boolean

  4. Undefined


Correct Option: A
Explanation:

In JavaScript, the Number data type is used to store whole numbers.

Which of the following is not a valid JavaScript data type?

  1. Number

  2. String

  3. Boolean

  4. Array


Correct Option: D
Explanation:

In JavaScript, Array is not a data type but a built-in object.

What is the data type of a variable that can store text?

  1. Number

  2. String

  3. Boolean

  4. Undefined


Correct Option: B
Explanation:

In JavaScript, the String data type is used to store text.

Which of the following is not a valid JavaScript operator?

  1. +

  2. -

  3. *

  4. /

  5. %


Correct Option: E
Explanation:

In JavaScript, % is not a valid operator.

What is the result of the following expression: 10 + 20?

  1. 30

  2. 40

  3. 50

  4. 60


Correct Option: A
Explanation:

In JavaScript, the + operator is used for addition. Therefore, the result of the expression 10 + 20 is 30.

What is the result of the following expression: 10 - 5?

  1. 5

  2. 10

  3. 15

  4. 20


Correct Option: A
Explanation:

In JavaScript, the - operator is used for subtraction. Therefore, the result of the expression 10 - 5 is 5.

What is the result of the following expression: 10 * 2?

  1. 20

  2. 30

  3. 40

  4. 50


Correct Option: A
Explanation:

In JavaScript, the * operator is used for multiplication. Therefore, the result of the expression 10 * 2 is 20.

What is the result of the following expression: 10 / 2?

  1. 5

  2. 10

  3. 15

  4. 20


Correct Option: A
Explanation:

In JavaScript, the / operator is used for division. Therefore, the result of the expression 10 / 2 is 5.

What is the result of the following expression: 10 % 3?

  1. 1

  2. 2

  3. 3

  4. 4


Correct Option: A
Explanation:

In JavaScript, the % operator is used for modulus. The modulus operator returns the remainder of the division of two numbers. Therefore, the result of the expression 10 % 3 is 1.

What is the data type of a variable that can store true or false?

  1. Number

  2. String

  3. Boolean

  4. Undefined


Correct Option: C
Explanation:

In JavaScript, the Boolean data type is used to store true or false values.

What is the result of the following expression: true && false?

  1. true

  2. false

  3. undefined

  4. null


Correct Option: B
Explanation:

In JavaScript, the && operator is used for logical AND. The logical AND operator returns true if both operands are true, and false otherwise. Therefore, the result of the expression true && false is false.

What is the result of the following expression: true || false?

  1. true

  2. false

  3. undefined

  4. null


Correct Option: A
Explanation:

In JavaScript, the || operator is used for logical OR. The logical OR operator returns true if either operand is true, and false otherwise. Therefore, the result of the expression true || false is true.

What is the result of the following expression: !true?

  1. true

  2. false

  3. undefined

  4. null


Correct Option: B
Explanation:

In JavaScript, the ! operator is used for logical NOT. The logical NOT operator returns true if the operand is false, and false otherwise. Therefore, the result of the expression !true is false.

What is the result of the following expression: !false?

  1. true

  2. false

  3. undefined

  4. null


Correct Option: A
Explanation:

In JavaScript, the ! operator is used for logical NOT. The logical NOT operator returns true if the operand is false, and false otherwise. Therefore, the result of the expression !false is true.

- Hide questions