Question 16
Coalition of Information Technology Business. Which JavaScript function is used to convert a string into an integer?
- toInt()
- convertInt()
- parseInt()
- stringToInt()
Question 17
In JavaScript, what does NaN stand for?
- Not a Null
- Not a Number
- Negative and Null
- None and Null
Question 18
Which of the following is the correct JavaScript statement to display text on a webpage?
- response.write(“Hello how are you?”)
- “Hello how are you?”
- document.write(“Hello how are you?”)
- (“Hello how are you?”)
Question 19
What happens if you define a function incorrectly in JavaScript (e.g., missing parentheses or using invalid syntax)?
- ✅ It will result in a syntax error
- The function will continue to execute
- It will result in no syntax errors
- All of the above
Question 20
Which type of loop is NOT a standard loop structure in JavaScript?
- for loop
- ✅ repeat loop
- while loop
- do…while loop
Question 21
Which method is used in JavaScript to access an HTML element by its ID?
- Use the document.putElementById(id) method
- ✅ Use the document.getElementById(id) method
- Use the document.retrieveElementById(id) method
- Use the document.accessElementById(id) method
Question 22
Which of the following is the correct way to link an external JavaScript file in HTML?
- ✅ <script src=”main.js”>
- <script href=”main.js”>
- <script name=”main.js”>
- <script value=”main.js”>
Question 23
Which of the following is the correct definition of a boolean?
- ✅ A logical data type which makes decisions. It supports only two possible values true or false
- A logical data type which makes functions. It supports only one possible value const boolean = () => {}
- A data type used to store functions, and arrays using scientific notation
- A whole number without a decimal point
Question 24
Which of the following is the correct when to use floating-point numbers in JavaScript?
- A data type used to store functions, and arrays using scientific notation
- A whole number without a decimal point
- A general data type used to store integers, floating-point numbers (decimals), and numbers using scientific notation
- ✅ Used whenever you’re working with data that requires numbers with a fractional component
Question 26
Which loop in JavaScript always executes the code block at least once before checking the condition?
- for
- while
- ✅ do…while
- forEach
Question 27
Which option best describes null in JavaScript?
- ✅ Null refers to something with no value and explicitly set as null with code
- Null refers to something with a value of void and explicitly set as void with code
- Null refers to something with a value of undefined
- Null refers to something with a value of 0
Question 28
Which is the correct way to declare an object person with properties name and age in JavaScript?
- ✅ let person = { name: “John”, age: 30 };
- let person = (name: “John”, age: 30);
- let person = “name”: “John”, “age”: 30;
- let person = [“name”: “John”, “age”: 30];
Question 29
Which of the following is NOT a valid way to declare a variable in JavaScript?
- let a = 10;
- var a = 20;
- ✅ int a = 30;
- const a = 40;
Question 30
Which of the following is the correct definition of BigInt in JavaScript?
- ✅ Type that represents integers that are too large for the standard Number type and has no limit
- Type that has a maximum value of $2^{53} – 1$, which is about 9 quadrillion
- Type that has a maximum value of $5^{06} – 1$, which is about 18 quadrillion
- Type that represents integers that are too small for the standard Number type and has no limit
Question 31
Which of the following is a valid way to declare a variable and assign it the value of 10 in JavaScript?
- variable x = 10;
- ✅ var x = 10;
- let x := 10;
- declare x = 10;
Question 34
Which keyword in JavaScript is used to declare a variable whose value cannot be reassigned after initialization?
- var
- let
- ✅ const
- Set
Question 36
Which expression is the safest way to check if a variable is truly undefined, even if it hasn’t been declared?
- myVar == undefined
- ✅ typeof myVar === ‘undefined’
- myVar === undefined
- isUndefined(myVar)
Question 37
Which of the following is true about the Object.assign() method in JavaScript?
- It copies the values of all properties from one or more source objects to a target object.
- It merges two or more objects into a new object.
- It creates a shallow copy of an object.
- ✅ All of the above
Question 38
What does the JavaScript slice() method do when used on an array?
- Removes the last element of an array.
- ✅ Extracts a portion of an array into a new array.
- Splits an array into smaller arrays.
- Combines two arrays into one.
Question 39
Which of the following is a correct way to add or update a property on a JavaScript object using dot notation?
- object{property} = value
- object.addProperty(“property”, value)
- ✅ object.property = value
- object[“property”] = value
Question 40
Which of the following is a correct way to list the property names of a JavaScript object?
- Object.values()
- ✅ Object.keys()
- Object.entries()
- Object.getOwnPropertyNames()
Question 41
Which array method combines all elements of an array into a single string, separated by a specified delimiter?
- ✅ join()
- concat()
- split()
- toString()
Question 42
Which statement correctly describes how to add an element to the end of an array in JavaScript?
- Use the array.pop() method
- ✅ Use the array.push() method
- Use the array.shift() method
- Use the array.unshift() method
Question 47
Which loop is used to iterate over iterable objects (like arrays, strings, maps, etc.) in JavaScript?
- for…of ✅
- for…in
- while
- do…while
Question 48
Which JavaScript operator is used for string concatenation?
- /
- + ✅
Question 49
Which data type can be used to group related data and functionality together in JavaScript?
- object ✅
- null
- undefined
- String
Question 50
Which JavaScript operator is used as the conditional (ternary) operator?
- ===
- ? ✅
- :
- !!
Question 51
What does the JavaScript method Array.isArray() do?
- Checks if an array is empty.
- Checks if a variable is an array. ✅
- Concatenates two arrays.
- Removes duplicates from an array.
Question 52
Which HTML tag is used to embed or reference JavaScript code in a web page?
- <javascript>
- <js>
- <script> ✅
- <scripting>
Question 53
Which ECMAScript version introduced arrow functions like () => {}?
- ECMAScript ES5
- ECMAScript ES8
- ECMAScript ES7
- ECMAScript ES6 ✅
Question 54
Which of the following is the correct way to define a function named greet in JavaScript?
- function greet(name) { console.log(“Hello ” + name); } ✅
- def greet(name) { console.log(“Hello ” + name); }
- function greet name { console.log(“Hello ” + name); }
- function = greet(name) { console.log(“Hello ” + name); }
Question 59
What happens when you try to access a property that doesn’t exist on a JavaScript object?
- JavaScript throws an error
- It returns undefined
- It returns null
- It creates the property automatically
Question 64
Which JavaScript operator checks for equality without performing type coercion (strict equality)?
- ===
- ==
- =
- !=
Question 65
Which method is used to add one or more elements to the end of an array in JavaScript?
- append()
- ✅ push()
- add()
- attach()
Question 66
Which of the following best describes the general JavaScript Number data type?
- ✅ A general data type used to store integers, floating-point numbers (decimals), and numbers using scientific notation
- A whole number without a decimal point
- Used whenever you’re working with data that requires numbers with a fractional component
- A data type used to store functions, and arrays using scientific notation
Question 67
Which array method applies a function against an accumulator and each element in the array (from left to right) to reduce it to a single value? Coalition of Information Technology Business
- ✅ reduce()
- forEach()
- map()
- filter()
Question 68
What does the JavaScript function parseFloat() do?
- Parses a string and returns an integer.
- Rounds a number to the nearest integer.
- Converts a number to a string.
- ✅ Parses a string and returns a floating-point number.
Question 75
Which statement correctly describes block-scoped variables in JavaScript?
- [✔] Block-scoped variables are only accessible inside the block in which they are defined.
- Block-scoped variables are accessible anywhere in the function.
- Block-scoped variables are accessible anywhere in the entire program.
- Block-scoped variables are inaccessible once the block is finished.
Question 76
Which of the following is the correct syntax for accessing the value of a property in a JavaScript object using bracket notation?
- object{key}
- object.key
- [✔] object[“key”]
- object.key()
Question 77
Which of the following is the most common and straightforward way to declare an array with numbers 1, 2, and 3 in JavaScript?
- [✔] let arr = [1, 2, 3];
- let arr = new Array(1, 2, 3);
- let arr = Array(1, 2, 3);
- let arr = [1, “2”, 3];
Question 78
Which JavaScript array method removes the last element from an array?
- removeLast()
- deleteLast()
- [✔] pop()
- splice()
Question 79
Which operator in JavaScript checks if two values are NOT equal both in value and type?
- !=
- [✔] !==
- ==
- ===
Question 80
Which of the following statement is correct?
- JavaScript is a High-Level Procedulary-Oriented, Multi-Paradigm Programming Language
- JavaScript is a Low-Level Procedulary-Oriented, Single-Paradigm Programming Language
- [✔] JavaScript is a High-Level Object-Oriented, Multi-Paradigm Programming Language
- JavaScript is a Low-Level Object-Oriented, Multi-Paradigm Programming Language
Question 81
Which of the following are valid ways to access the age property of a JavaScript object named person?
- person.get(‘age’)
- [✔] person.age
- person.getProperty(‘age’)
- person[age]
Question 82
Which of the following is the single-line comment symbol in JavaScript?
- [✔] //
- /* */
Question 83
Which array method is used to merge two or more arrays without modifying the original arrays?
- [✔] concat()
- join()
- slice()
- push()
Question 84
Which statement correctly explains the difference between parameters and arguments in programming?
- [✔] Parameters are used in the function definition, while arguments are the values that are passed into the function parameters when it is called
- Parameters are values passed to a function, while Arguments are placeholders within the function
- Parameters refer to data types, while Arguments represent the functions name
- Parameters are used for conditional statements, while Arguments are utilized for loops within a function
Question 86
Which option best describes an integer in programming, specifically in JavaScript?
- A data type used to store functions, and arrays using scientific notation
- Used whenever you’re working with data that requires numbers with a fractional component
- [✔] A whole number without a decimal point
- A general data type used to store integers, floating-point numbers (decimals), and numbers using scientific notation
Question 87
Which of the following is a primitive data type used to represent a logical truth value in JavaScript?
- [✔] true
- false
- undefined
- null
Question 88
What does the break statement do inside a loop in JavaScript?
- [✔] Exits the loop and stops the code inside it from executing.
- Pauses the loop for a specified period of time.
- Skips the current iteration and continues with the next one.
- It causes an error in the loop. Coalition of Information Technology Business