JavaScript Fundamentals

Test your knowledge of JavaScript basics including variables, operators, loops, functions, arrays, comments, and browser interaction.

22 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

Is JavaScript case-sensitive?

  1. No
  2. Yes
Question 2 Multiple Choice (Single Answer)

What will the following code return: Boolean(10 > 9)?

  1. NaN
  2. false
  3. true
Question 3 Multiple Choice (Single Answer)

Which operator is used to assign a value to a variable?

  1. *
  2. =
  3. -
  4. x
Question 4 Multiple Choice (Single Answer)

How do you declare a JavaScript variable?

  1. variable carName;
  2. v carName;
  3. var carName;
Question 5 Multiple Choice (Single Answer)

Which event occurs when the user clicks on an HTML element?

  1. onchange
  2. onclick
  3. onmouseclick
  4. onmouseover
Question 6 Multiple Choice (Single Answer)

How can you detect the client's browser name?

  1. browser.name
  2. navigator.appName
  3. client.navName
Question 7 Multiple Choice (Single Answer)

JavaScript is the same as Java.

  1. True
  2. False
Question 8 Multiple Choice (Single Answer)

What is the correct JavaScript syntax for opening a new window called "w2" ?

  1. w2 = window.new("http://www.site.com");
  2. w2 = window.open"http://site.com");
Question 9 Multiple Choice (Single Answer)

How do you find the number with the highest value of x and y?

  1. Math.ceil(x, y)
  2. Math.max(x, y)
  3. top(x, y)
  4. ceil(x, y)
Question 10 Multiple Choice (Single Answer)

How do you round the number 7.25, to the nearest integer?

  1. Math.round(7.25)
  2. rnd(7.25)
  3. Math.rnd(7.25)
  4. round(7.25)
Question 11 Multiple Choice (Single Answer)

What is the correct way to write a JavaScript array?

  1. var colors = "red", "green", "blue"
  2. var colors = 1 = ("red"), 2 = ("green"), 3 = ("blue")
  3. var colors = (1:"red", 2:"green", 3:"blue")
  4. var colors = ["red", "green", "blue"]
Question 12 Multiple Choice (Single Answer)

How to insert a comment that has more than one line?

  1. <!--This comment hasmore than one line-->
  2. //This comment has more than one line//
  3. /This comment hasmore than one line/
Question 13 Multiple Choice (Single Answer)

How can you add a comment in a JavaScript?

  1. //This is a comment
  2. <!--This is a comment-->
  3. 'This is a comment
Question 14 Multiple Choice (Single Answer)

How does a FOR loop start?

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

How does a WHILE loop start?

  1. while (i <= 10)
  2. while (i <= 10; i++)
  3. while i = 1 to 10
Question 16 Multiple Choice (Single Answer)

How to write an IF statement for executing some code if "i" is NOT equal to 5?

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

How to write an IF statement in JavaScript?

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

How do you call a function named "myFunction"?

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

How do you write "Hello World" in an alert box?

  1. alert("Hello World");
  2. msg("Hello World");
  3. alertBox("Hello World");
  4. msgBox("Hello World");
Question 20 Multiple Choice (Single Answer)

The external JavaScript file must contain the <script> tag.

  1. False
  2. true
Question 21 Multiple Choice (Single Answer)

Where is the correct place to insert a JavaScript?

  1. The <body> section
  2. The <head> section
  3. Both the <head> section and the <body> section are correct
Question 22 Multiple Choice (Single Answer)

Inside which HTML element do we put the JavaScript?

  1. <scripting>
  2. <script>
  3. <javascript>
  4. <js>