Variables
Control-Flow (If-else)
Loops
Arrays
Objects
100

What keyword is used to declare a variable in JavaScript?

var, let, or const.

100

What keyword is used to create a conditional statement in JavaScript?


if

100

What is the purpose of a for loop in JavaScript?

A for loop is used for iterating over a sequence (such as an array) with a predetermined number of iterations.

100

How do you create an empty array in JavaScript?

var emptyArray = [];

100

How to create an object?

var object = {};

200

What is the difference between let, const, and var when declaring variables?

var has function-level scope (global), while let and const have block-level scope (local). const cannot be reassigned, but let and var can.

200

What happens when an If statements conditional is not true?

Nothing happens

200

How does a while loop differ from a for loop?

A while loop continues executing as long as a specified condition is true, whereas a for loop is typically used for a fixed number of iterations

200

How can you access the third element in an array using its index?

array[2]

200

What is an object in JavaScript?

An object is a collection of key-value pairs where keys are strings (or symbols) and values can be of any data type.

300

What is the value of a variable without declaring its value? 

undefined

300

What is the difference between == and === in JavaScript?

== is equal operator but === strictly equal operator

300

When might you use a do-while loop instead of a while or for loop?

You might use a do-while loop when you want to ensure that the loop code block runs at least once, regardless of the condition

300

How can you add an element to the end of an array in JavaScript?

push()

300

How do you add a new property to an existing object in JavaScript?


myObject.newProperty = "new value"; 

myObject["newProperty"] = "new value";

400

How will you declare a variable in JavaScript that stores the string Tom?

var name = 'Tom';

400

How do you write an if statement that checks if a number is even?

if (num % 2 === 0)

400

Explain the purpose of the break and continue statements in loops

break is used to exit a loop prematurely, while continue is used to skip the current iteration and continue to the next one

400

What keyword is used to iterate through an array?

array.length

400

What values can be stored in an object?

All data types (strings, numbers, arrays, functions, objects)

500

What is the value of a variable that has not been initialized?

undefined.

500

Explain the concept of a ternary operator in JavaScript and provide an example

The ternary operator (? :) is a shorthand for writing if-else statements. Example: let result = (condition) ? "True" : "False";

500

Write a for loop that iterates from 1 to 10 and prints the square of each number

for (var i = 1; i <= 10; i++) 

{  console.log(i * i); }


500

What is the use of an array?

Collection of variables, it is used to group related values into one variable.

500

What is the difference of objects and arrays?

An object is a key-value pair, and the array are index based.

M
e
n
u