Functions Of Java Script Questions

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By Saifullah
S
Saifullah
Community Contributor
Quizzes Created: 3 | Total Attempts: 2,033
Questions: 20 | Attempts: 218

SettingsSettingsSettings
Functions Of Java Script Questions - Quiz

Questions and Answers
  • 1. 

    Inside which HTML element do we put the JavaScript?

    • A.

      1

    • B.

      2

    • C.

      3

    • D.

      4

    Correct Answer
    B. 2
    Explanation
    In HTML, JavaScript code is typically placed inside the `` element. This element is used to define client-side scripts, allowing JavaScript to be embedded directly within an HTML document. By placing JavaScript code within the `` tags, it can be executed and interact with the HTML elements on the page. Therefore, the correct answer is 2.

    Rate this question:

  • 2. 

    Which of the following JavaScript statements use arrays?

    • A.

      SetTimeout("a["+i+"]",1000)

    • B.

      K = a & i

    • C.

      K = a(i)

    Correct Answer
    A. SetTimeout("a["+i+"]",1000)
    Explanation
    The correct answer is setTimeout("a["+i+"]",1000) because it uses an array (a) and accesses a specific element of the array (a[i]) within the setTimeout function.

    Rate this question:

  • 3. 

    Which property would you use to redirect visitor to another page?

    • A.

      Window.location.href

    • B.

      Document.href

    • C.

      Java.redirect.url

    • D.

      Link.redirect.href

    Correct Answer
    A. Window.location.href
    Explanation
    The correct answer is window.location.href. This property is used to redirect a visitor to another page. It is a part of the window object in JavaScript and allows the manipulation of the current URL. By assigning a new URL to this property, the browser automatically navigates to the specified page. The other options mentioned, such as document.href, java.redirect.url, and link.redirect.href, are not valid properties or methods for redirecting visitors to another page.

    Rate this question:

  • 4. 

    Wich best describe void?

    • A.

      A method

    • B.

      A function

    • C.

      An operator

    • D.

      A statement

    Correct Answer
    C. An operator
    Explanation
    Void is not a method, function, or statement. In programming, void is a data type that represents the absence of a value. It is often used to indicate that a method or function does not return any value. However, void is not an operator either, as operators are symbols or keywords used to perform specific operations on data. Hence, the correct answer is that void is not an operator.

    Rate this question:

  • 5. 

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

    • A.

      Response.write("Hello World")

    • B.

      Document.write("Hello World")

    • C.

      ("Hello World")

    • D.

      Echo("Hello World")

    Correct Answer
    B. Document.write("Hello World")
    Explanation
    The correct JavaScript syntax to write "Hello World" is document.write("Hello World"). This method is used to display text or HTML content on a web page. It allows the developer to dynamically generate content and insert it into the document.

    Rate this question:

  • 6. 

    How do you call a function named "myFunction"?

    • A.

      Call myFunction()

    • B.

      MyFunction()

    • C.

      Call function myFunction

    Correct Answer
    B. MyFunction()
    Explanation
    To call a function named "myFunction", you need to use the syntax "myFunction()". This will execute the code inside the function and perform the desired actions or computations.

    Rate this question:

  • 7. 

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

    • A.

      If i==5 then

    • B.

      If i=5 then

    • C.

      If (i==5)

    • D.

      If i=5

    Correct Answer
    C. If (i==5)
    Explanation
    The correct answer is "if (i==5)". This is the correct syntax for writing a conditional statement in many programming languages, including C++, Java, and Python. The "if" keyword is used to start the conditional statement, followed by the condition in parentheses. In this case, the condition is "i==5" which checks if the value of "i" is equal to 5. If the condition is true, then the statements inside the curly braces following the "if" statement will be executed.

    Rate this question:

  • 8. 

    How many different kind of loops are there in JavaScript?

    • A.

      Two. The "for" loop and the "while" loop

    • B.

      Four. The "for" loop, the "while" loop, the "do...while" loop, and the "loop...until" loop

    • C.

      One. The "for" loop

    Correct Answer
    A. Two. The "for" loop and the "while" loop
    Explanation
    The correct answer is two because JavaScript has two different types of loops: the "for" loop and the "while" loop. These loops allow for repetitive execution of a block of code until a certain condition is met. The "for" loop is typically used when the number of iterations is known, while the "while" loop is used when the number of iterations is uncertain and depends on a condition.

    Rate this question:

  • 9. 

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

    • A.

      If (i 5)

    • B.

      If (i != 5)

    • C.

      If =! 5 then

    • D.

      If 5

    Correct Answer
    B. If (i != 5)
    Explanation
    The correct answer is "if (i != 5)". This conditional statement checks if the variable "i" is not equal to 5. If the condition is true, the specified statements within the if block will be executed.

    Rate this question:

  • 10. 

    How does a "for" loop start?

    • A.

      For (i = 0; i

    • B.

      For (i = 0; i

    • C.

      For i = 1 to 5

    • D.

      For (i

    Correct Answer
    B. For (i = 0; i
    Explanation
    The correct answer is "for (i = 0; i < 5; i++)". This is the standard syntax for a "for" loop in most programming languages. It consists of three parts: the initialization (i = 0), the condition (i < 5), and the increment (i++). The loop will start by initializing the variable i to 0, then it will check if the condition i < 5 is true. If it is, the loop will execute the code inside the loop body. After each iteration, the increment will be executed (i++), updating the value of i. The loop will continue as long as the condition is true and will stop when the condition becomes false.

    Rate this question:

  • 11. 

    What is the correct way to write a JavaScript array?

    • A.

      Var txt = new Array("tim","shaq","kobe")

    • B.

      Var txt = new Array="tim","shaq","kobe"

    • C.

      Var txt = new Array(1:"tim",2:"shaq",3:"kobe")

    Correct Answer
    A. Var txt = new Array("tim","shaq","kobe")
    Explanation
    The correct way to write a JavaScript array is by using the syntax var txt = new Array("tim","shaq","kobe"). This syntax creates a new array object called "txt" with three elements: "tim", "shaq", and "kobe".

    Rate this question:

  • 12. 

    Onclick is equivalent to which two events in sequence

    • A.

      Onmouseover and onmousedown

    • B.

      Onmousedown and onmouseout

    • C.

      Onmousedown and onmouseup

    • D.

      Onmouseup and onmouseout

    Correct Answer
    C. Onmousedown and onmouseup
    Explanation
    The onclick event is triggered when a user clicks on an element. This event is equivalent to the onmousedown event, which occurs when the mouse button is pressed down, and the onmouseup event, which occurs when the mouse button is released. Therefore, the correct answer is "onmousedown and onmouseup".

    Rate this question:

  • 13. 

    You define an array using

    • A.

      Var myarray = new Array();

    • B.

      Var myarray = array new;

    • C.

      Var new Array() = myarray;

    • D.

      Var new array = myarray;

    Correct Answer
    A. Var myarray = new Array();
    Explanation
    The correct answer is "var myarray = new Array();". This is the correct way to define an array in JavaScript. The "new Array()" syntax is used to create a new instance of an array object, and assigning it to the variable "myarray" allows you to access and manipulate the array using that variable. The other options provided in the question are incorrect syntax and would result in a syntax error.

    Rate this question:

  • 14. 

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

    • A.

      Math.rnd(8.25)

    • B.

      Math.round(8.25)

    • C.

      Round(8.25)

    • D.

      Rnd(8.25)

    Correct Answer
    B. Math.round(8.25)
    Explanation
    The correct answer is Math.round(8.25). The Math.round() function is used to round a number to the nearest whole number. In this case, 8.25 is rounded to 8.

    Rate this question:

  • 15. 

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

    • A.

      Math.max(6,8)

    • B.

      Top(6,8)

    • C.

      Ceil(6,8)

    • D.

      Math.ceil(6,8)

    Correct Answer
    A. Math.max(6,8)
    Explanation
    The correct answer is Math.max(6,8). This is because the Math.max() function is used to find the largest number among the given inputs. In this case, the function is comparing the numbers 6 and 8 and returning the larger number, which is 8.

    Rate this question:

  • 16. 

    How do you find the client's browser name?

    • A.

      Navigator.appName

    • B.

      Client.navName

    • C.

      Browser.name

    Correct Answer
    A. Navigator.appName
    Explanation
    The correct answer is navigator.appName. The navigator.appName property is used to find the name of the client's browser. It returns the name of the browser as a string. This property is commonly used in JavaScript to detect the browser type and perform browser-specific actions or optimizations.

    Rate this question:

  • 17. 

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

    • A.

      New("http://www.ex-designz.net","window5")

    • B.

      Window.open("http://www.ex-designz.net","window5")

    • C.

      Open.newwindow("http://www.ex-designz.net","window5")

    • D.

      New.window("http://www.ex-designz.net","window5")

    Correct Answer
    B. Window.open("http://www.ex-designz.net","window5")
    Explanation
    The correct JavaScript syntax for opening a new window called "window5" is window.open("http://www.ex-designz.net","window5"). This syntax uses the window.open() method to open a new window with the specified URL and window name.

    Rate this question:

  • 18. 

    How do you put a message in the browser's status bar?

    • A.

      Window.status = "put your message here"

    • B.

      Statusbar = "put your message here"

    • C.

      Status("put your message here")

    • D.

      Window.status("put your message here")

    Correct Answer
    A. Window.status = "put your message here"
    Explanation
    The correct answer is "window.status = 'put your message here'". This is because the "window.status" property allows you to set the text that appears in the browser's status bar. By assigning a message to this property, you can display your desired message in the status bar. The other options provided ("statusbar = 'put your message here'", "status('put your message here')", "window.status('put your message here')") are incorrect and will not achieve the desired result.

    Rate this question:

  • 19. 

    EJERCICIO: Definir una función que muestre información sobre una cadena de texto que se le pasa como argumento. A partir de la cadena que se le pasa, la función determina si esa cadena está formada sólo por mayúsculas, sólo por minúsculas o por una mezcla de ambas.

  • 20. 

    El factorial de un número entero n es una operación matemática que consiste en multiplicar todos los factores n x (n-1) x (n-2) x ... x 1. Así, el factorial de 5 (escrito como 5!) es igual a: 5! = 5 x 4 x 3 x 2 x 1 = 120 Utilizando la estructura for, crear un script que calcule el factorial de un número entero.

Quiz Review Timeline +

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

  • Current Version
  • Mar 21, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Nov 27, 2015
    Quiz Created by
    Saifullah
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.