JavaScript Quiz: MCQ Trivia Exam!

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Gary Neslon
G
Gary Neslon
Community Contributor
Quizzes Created: 1 | Total Attempts: 563
| Attempts: 563 | Questions: 20
Please wait...
Question 1 / 20
0 %
0/100
Score 0/100
1. When linking to an external JavaScript file what extension would the file have?

Explanation

When linking to an external JavaScript file, the file would have a .js extension. This is the standard file extension for JavaScript files, which allows the browser to recognize and interpret the code correctly. The .javascript, .java, and .JSCRIPT extensions are not commonly used for JavaScript files.

Submit
Please wait...
About This Quiz
JavaScript Quiz: MCQ Trivia Exam! - Quiz

Dive into the JavaScript Quiz: MCQ Trivia Exam to test and enhance your understanding of JavaScript functions, syntax, and best practices. This quiz assesses key skills in coding... see morewith JavaScript, ideal for learners aiming to improve their web development capabilities. see less

2. When joining 2 strings together in JavaScript this is known as?

Explanation

Concatenation is the correct answer because it refers to the process of combining two or more strings together in JavaScript. It involves joining the characters or elements of one string to the end of another string, resulting in a new string that contains the combined values. This term is commonly used in programming to describe the action of merging strings.

Submit
3. A Global variable can be accessed from any part of your program.

Explanation

A global variable is a variable that is defined outside of any function and can be accessed from any part of the program. This means that it is not limited to a specific scope and can be used in multiple functions or modules. Therefore, the statement "A Global variable can be accessed from any part of your program" is true.

Submit
4. If a variable is created inside a function the variable scope would be known as...

Explanation

When a variable is created inside a function, its scope is limited to that specific function. This means that the variable can only be accessed and used within that function. This type of scope is known as "local" because it is restricted to a specific portion of the code. Local variables are useful for storing temporary or intermediate values that are only needed within a particular function. They are not accessible outside of the function, which helps to prevent naming conflicts and keeps the code organized.

Submit
5. In the code below what word describes each time the loop goes round? for(i = 0;  i < 10;  i++)  { console.log( i );

Explanation

The word that describes each time the loop goes round is "iteration". In this code, the loop is set to execute as long as the variable "i" is less than 10. Each time the loop iterates, the value of "i" is printed to the console. Therefore, "iteration" accurately describes the process of the loop going round and executing its code block repeatedly.

Submit
6. Will the following condition return true OR false ?var x = 6;if( x >= 6 )  {console.log("Yes " +  x + "  is a Great Number")}

Explanation

The condition in the given code is checking if the value of variable x is greater than or equal to 6. Since the value of x is 6, which is equal to 6, the condition will evaluate to true. Therefore, the code inside the if statement will be executed and the message "Yes 6 is a Great Number" will be printed.

Submit
7. What would best describe the code below: var nums = [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ];

Explanation

The code provided initializes a variable called "nums" with an array of integers. The array contains the numbers 1, 2, 3, 4, 5, 6, 7, 8, and 9. Therefore, the correct answer is "An array of integers."

Submit
8. JavaScript code will load before the webpage if stored in the head tags.

Explanation

When JavaScript code is placed within the head tags of an HTML document, it will load before the webpage is fully rendered. This means that any JavaScript functions or actions specified in the code will be executed before the rest of the webpage content is displayed. This can be useful for situations where the JavaScript code needs to manipulate or interact with elements on the webpage as soon as possible. Placing JavaScript in the head tags can also ensure that any necessary scripts are loaded and ready to be used before the rest of the page is loaded.

Submit
9. It can be considered good practice to insert JavaScript code before the closing body ta, as this allows the HTML to load first

Explanation

Inserting JavaScript code before the closing body tag is considered good practice because it allows the HTML to load first. By placing the JavaScript code at the end of the body, it ensures that the HTML elements have been parsed and rendered by the browser before any JavaScript code is executed. This can improve the overall performance and user experience of the website, as it allows the page content to be displayed to the user more quickly. Additionally, it can prevent any potential issues or errors that may arise if the JavaScript code tries to manipulate HTML elements that have not yet been loaded.

Submit
10. Name two different ways to call a function.

Explanation

The correct answer is "When it is invoked from JavaScript code" and "When an event occurs (when a user clicks a button)". These two ways refer to different ways of calling a function in JavaScript. The first way is by directly invoking the function from JavaScript code using its name followed by parentheses. The second way is by attaching the function as an event handler to an HTML element or DOM object, so that it is called when a specific event, such as a button click, occurs.

Submit
11. JavaScript is used to...

Explanation

JavaScript is used to add interactivity to HTML pages. It allows web developers to create dynamic and interactive elements on a webpage, such as form validation, image sliders, and interactive maps. By using JavaScript, users can interact with the webpage, input data, and receive responses or feedback in real-time. This makes the webpage more engaging and user-friendly. JavaScript is primarily a client-side scripting language, meaning it runs on the user's web browser rather than the server, making it an essential tool for enhancing the functionality and user experience of HTML pages.

Submit
12. When Developing Software - check the boxes that would be considered good practice.

Explanation

Good software development practices include appropriate naming of variables, as it improves code readability and makes it easier to understand the purpose of each variable. Appropriate description/naming of functions is also important as it helps other developers understand the functionality of each function. Commenting all logic in the code is crucial for future reference and collaboration, as it provides explanations and context for the code. However, using a cool theme is not considered a good practice in software development as it is unrelated to the functionality and quality of the software.

Submit
13. Which Animal will the if statement display in the alert box? var animals = [ "Dog", "Cat", "Lion", "Bird", "Duck" ]; for( i = 0; i < animals.length; i++ ) { if( i === 4) { alert("The animal name is " + animals[ i ] ); }else{console.log(animals[ i ]); } }

Explanation

The if statement in the code checks if the value of i is equal to 4. When i is equal to 4, the alert box will display "The animal name is Duck". Therefore, the correct answer is Duck.

Submit
14. Which one of the choices below is considered a selection construct in programming?

Explanation

The choice "if...else" is considered a selection construct in programming because it allows the program to make decisions based on certain conditions. With the "if" statement, the program checks if a condition is true and executes a block of code if it is. If the condition is false, the program can then execute an alternative block of code using the "else" statement. This selection construct is commonly used to control the flow of the program based on different conditions.

Submit
15. In the loop below when i equals 2 what color will be displayed in the console? var colours = [red, green, blue]; for(i = 0;  i < colours.length;  i++)  { console.log(colours[i]); }

Explanation

The given loop iterates over the array "colours" and prints each element to the console. Since the loop starts at index 0 and increments the value of "i" by 1 with each iteration, when "i" equals 2, the third element of the array will be printed, which is "blue".

Submit
16. JavaScript is commonly known as...

Explanation

JavaScript is commonly known as a client-side scripting language because it is primarily used to add interactivity and dynamic behavior to web pages on the client side, meaning it runs on the user's web browser. It allows for the manipulation of HTML elements, handling user events, and making asynchronous requests to the server. While JavaScript can also be used on the server side with platforms like Node.js, its main purpose and widespread usage is for client-side scripting.

Submit
17. Which part of the following code is the conditional statement? if ( x > 5)  { console.log("Good Morning"); }else{"Goodnight"}

Explanation

The conditional statement in the given code is "( x > 5)". This is the part of the code that is being evaluated to determine whether the condition is true or false. If the condition is true, the code inside the if block will be executed, which in this case is "console.log("Good Morning")". If the condition is false, the code inside the else block will be executed, which is missing in the given code but should be "console.log("Goodnight")".

Submit
18. A user defined function or a built in function can have a list of.....

Explanation

A user-defined function or a built-in function can have a list of parameters. Parameters are variables that are used to pass values into a function. They allow the function to work with different values each time it is called. By specifying parameters, the function can be more flexible and reusable, as it can be used with different input values.

Submit
19. What are the variables used for?

Explanation

Variables are used for storing different types of data in code. In this case, the variables are used for storing integers and strings for manipulation in the code. Integers can be used for mathematical calculations and storing numerical values, while strings are used for storing text or characters. These variables can be manipulated and used in various ways within the code to perform different operations or tasks.

Submit
20. When calling a function you pass in ......

Explanation

When calling a function, you pass in arguments. Arguments are the values or variables that are passed into a function when it is called. These arguments can be used within the function to perform certain operations or calculations. By passing in arguments, you can customize the behavior of the function and make it more flexible and reusable.

Submit
View My Results

Quiz Review Timeline (Updated): Sep 20, 2024 +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Sep 20, 2024
    Quiz Edited by
    ProProfs Editorial Team
  • May 03, 2017
    Quiz Created by
    Gary Neslon
Cancel
  • All
    All (20)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
When linking to an external JavaScript file what extension would the...
When joining 2 strings together in JavaScript this is known as?
A Global variable can be accessed from any part of your program.
If a variable is created inside a function the variable scope would be...
In the code below what word describes each time the loop goes round?...
Will the following condition return true OR false ?var x = 6;if( x...
What would best describe the code below:...
JavaScript code will load before the webpage if stored in the head...
It can be considered good practice to insert JavaScript code before...
Name two different ways to call a function.
JavaScript is used to...
When Developing Software - check the boxes that would be considered...
Which Animal will the if statement display in the alert box? ...
Which one of the choices below is considered a selection construct in...
In the loop below when i equals 2 what color will be displayed in the...
JavaScript is commonly known as...
Which part of the following code is the conditional statement? ...
A user defined function or a built in function can have a list of.....
What are the variables used for?
When calling a function you pass in ......
Alert!

Advertisement