Basic Javascript Quiz

Test your knowledge of basic JavaScript programming concepts including syntax, functions, conditionals, loops, arrays, Math methods, and string operations.

15 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

Inside which HTML element do we put the JavaScript?

  1. <scripting>
  2. <javascript>
  3. <script>
  4. <js>
Question 2 Multiple Choice (Single Answer)

What is the correct JavaScript syntax to write "Hello World"?

  1. response.write("Hello World")
  2. document.write("Hello World")
  3. ("Hello World")
  4. echo("Hello World")
Question 3 Multiple Choice (Single Answer)

How do you call a function named "myFunction"?

  1. call function myFunction
  2. myFunction()
  3. call myFunction()
Question 4 Multiple Choice (Single Answer)

How do you write a conditional statement for executing some statements only if "i" is equal to 5?

  1. if i==5 then
  2. if i=5 then
  3. if (i==5)
  4. if i=5
Question 5 Multiple Choice (Single Answer)

How do you write a conditional statement for executing some statements only if "i" is NOT equal to 5?

  1. if (i <> 5)
  2. if (i != 5)
  3. if =! 5 then
  4. if <> 5
Question 6 Multiple Choice (Single Answer)

How many different kind of loops are there in JavaScript?

  1. Two. The "for" loop and the "while" loop
  2. Four. The "for" loop, the "while" loop, the "do...while" loop, and the "loop...until" loop
  3. One. The "for" loop
Question 7 Multiple Choice (Single Answer)

How does a "for" loop start?

  1. for (i = 0; i <= 5)
  2. for (i = 0; i <= 5; i++)
  3. for i = 1 to 5
  4. for (i <= 5; i++)
Question 8 Multiple Choice (Single Answer)

What is the correct way to write a JavaScript array?

  1. var txt = new Array(1:"tim",2:"shaq",3:"kobe")
  2. var txt = new Array="tim","shaq","kobe"
  3. var txt = new Array("tim","shaq","kobe")
Question 9 Multiple Choice (Single Answer)

How do you round the number 8.25, to the nearest whole number?

  1. Math.rnd(8.25)
  2. Math.round(8.25)
  3. round(8.25)
  4. rnd(8.25)
Question 10 Multiple Choice (Single Answer)

How do you find the largest number of 6 and 8?

  1. Math.max(6,8)
  2. top(6,8)
  3. ceil(6,8)
  4. Math.ceil(6,8)
Question 11 Multiple Choice (Single Answer)

You work on a JavaScript project. How do you prompt users with messages and at the same time requesting user inputs?

  1. Alert()
  2. Display()
  3. Prompt()
  4. Confirm()
Question 12 Multiple Choice (Single Answer)

Which of the following is the correct syntax of FOR?

  1. for ( increment; initialize; test)
  2. for ( initialize; test), increment
  3. for ( initialize; test; increment)
  4. for ( test; initalize; increment)
Question 13 Multiple Choice (Single Answer)

In your JavaScript code, how do you find out which character occurs at the 5th position in a string "How are you"?

  1. Substring()
  2. String()
  3. Stringlength()
  4. CharAt()
Question 14 Multiple Choice (Single Answer)

Which of the following do you use for a multi-way branch?

  1. If
  2. Ifthen
  3. Ifelse
  4. switch
  5. for
Question 15 Multiple Choice (Single Answer)

You want to design a form validation mechanism. Using string methods, which of the following are the steps involved ?

  1. Check for the presence of certain characters
  2. Check the position of substrings
  3. Test the length of data
  4. Check the variable type of the strings
  5. Either ABC