JavaScript Quiz

The JavaScript practice quiz is designed to quiz how well you understand JavaScript. The quiz primarily focuses on DOM manipulation, but covers the fundamentals of JavaScript. After completing the practice quiz, feel free to move on to server side programming languages.

1. What is the symbol(s) to comment out one line in JavaScript?

 
 
 
 

2. How do you create a variable x that is equal to the string “Hello”?

 
 
 
 

3. How do you create a variable x that is equal to the integer 4?

 
 
 
 

4. If the variable x is already defined and equals 4. Now, if the statement is “document.write(x++);”, what would be displayed in the browser?

 
 
 
 

5. If x equals 7, and the only other statement is x = x % 3, what would be the new value of x?

 
 
 
 

6. Which of the following is not a comparison operator used in an if statement?

 
 
 
 

7. What is the keyword inside of a switch statement to create a condition?

 
 
 
 

8. What is the keyword to define a function in JavaScript?

 
 
 
 

9. Which of the following is an acceptable declaration of a for loop?

 
 
 
 

10. In a do while loop, which of the following is correct?

 
 
 
 

11. What two statements can you use in your JavaScript to handle errors?

 
 
 
 

12. What statement can you use to completely exit a loop and continue on through your code?

 
 
 
 

13. What statement can you use to exit the current iteration of the loop, where if the condition is still satisfied, you would proceed through the next loop?

 
 
 
 

14. In the string variable ‘I’m awesome’, would throw an error. Which of the following is a correct way to correct this problem?

 
 
 
 

15. What is a correct way to get an HTML element by its id?

 
 
 
 

16. What is the correct way to get an HTML element by its name?

 
 
 
 

17. How would you get the number of characters in the string variable example?

 
 
 
 

18. How would you break up a string variable, example, into separate characters?

 
 
 
 

19. In JavaScript, how to you convert a string to lower case?

 
 
 
 

20. In a JavaScript regular expressions, what does ‘/g’ mean?

 
 
 
 

21. How do you create an array in JavaScript?

 
 
 
 

22. How would you create a new date object in JavaScript?

 
 
 
 

23. How would you round up a number with a decimal to the nearest integer?

 
 
 
 

24. Internal JavaScript code is encased in what tag?

 
 
 
 

25. Which of the following can JavaScript not do?

 
 
 
 

Question 1 of 25