JavaScript Test: Ultimate Trivia Quiz!

35 Questions | Total Attempts: 41

SettingsSettingsSettings
Please wait...
JavaScript Test: Ultimate Trivia Quiz!

.


Questions and Answers
  • 1. 
    Evaluate the following: undefined + 2
    • A. 

      Type Error

    • B. 

      NaN

    • C. 

      Undefined

    • D. 

      2

  • 2. 
    Given x = new Date(), how do you represent x as a String in universal time (time zone +0000)?
    • A. 

      X.getUTC();

    • B. 

      X.getUTCDate();

    • C. 

      X.toUTCString();

  • 3. 
    What does JSON stand for?
    • A. 

      JavaScript Oriented Notation

    • B. 

      JavaScript Object Notation

    • C. 

      JavaScript Online Notation

  • 4. 
    Given the following, what is the value of x? var x = typeof "abc";
    • A. 

      Abc

    • B. 

      String

    • C. 

      Undefined

    • D. 

      Error

  • 5. 
    Variable x has a value of 5. Variable y has a value of 7 x < 7 && y > 6
    • A. 

      True

    • B. 

      False

  • 6. 
    You need to update the content of a <div> using the following code, complete the missing part <div id="myDiv"></div> <script> document.getElementById('myDiv').MISSING_PART = "new content" </script>
    • A. 

      Innerhtml

    • B. 

      InnerHtml

    • C. 

      InnterHtml

    • D. 

      InnerHTML

  • 7. 
    How to access the current element using DOM <input type="radio" name="gender" value="Male">
    • A. 

      Document.getElementById

    • B. 

      Document.getElementByName

    • C. 

      Document.getElementsByName

    • D. 

      Document.getElement

  • 8. 
    Which of the following events is used to handle the user click action
    • A. 

      Click

    • B. 

      Clicked

    • C. 

      Onclick

  • 9. 
    How do you use JavaScript via an external file ?
    • A. 

      < script url = "filename.js" > < / script >

    • B. 

      < script rel = "filename.js" > < / script >

    • C. 

      < script src = "filename.js" > < / script >

    • D. 

      < script href = "filename.js" > < / script >

  • 10. 
    You have to change the background color of the page programmatically, which of the following instructions is correct ?
    • A. 

      Document.body.background = 'red'

    • B. 

      Document.body.color = 'red'

    • C. 

      Document.body.style.background = 'red'

    • D. 

      Document.body.style.color = 'red'

  • 11. 
    Within innerHTML, can you create HTML markup content and append it to the page
    • A. 

      Yes

    • B. 

      No

  • 12. 
    To get value from user input we use which box ?
    • A. 

      Confirm

    • B. 

      Prompt

    • C. 

      Alert

    • D. 

      None of the above

  • 13. 
    In do-while .. while with condition required ';' at the end of ()
    • A. 

      True

    • B. 

      False

  • 14. 
    Where do we start a javascript code ?
    • A. 

      In the < javascript > tag

    • B. 

      In the < code > tag

    • C. 

      In the < script > tag

    • D. 

      None of the above

  • 15. 
    Where the < script > tag can be used
    • A. 

      In the < head > tag

    • B. 

      In the < body > tag

    • C. 

      Both < head > and < body > tags

  • 16. 
    Is javascript case sensitive ?
    • A. 

      True

    • B. 

      False

  • 17. 
    To convert string to number, which function do we use ?
    • A. 

      ParseNumber

    • B. 

      ParseString

    • C. 

      ParseInt

    • D. 

      ParseDouble

  • 18. 
    In javascript, is it required having semi-colon " ; " at the end of the statement ?
    • A. 

      True

    • B. 

      False

  • 19. 
    How do you check what the type of a value in variable x is?
    • A. 

      Gettype(x)

    • B. 

      Typeof(x)

    • C. 

      Object.type(x)

    • D. 

      X.type

  • 20. 
    What is the value of the following express: 8 % 3
    • A. 

      5

    • B. 

      2

    • C. 

      24

    • D. 

      NaN

  • 21. 
    What's the output of the following code var name = 'John', age = 20 console.log(`Hi, my name is ${name.toUpperCase()} and I'm ${++age} years old`)
    • A. 

      Hi, my name is John and I'm 20 years old

    • B. 

      Hi, my name is John and I'm 21 years old

    • C. 

      Hi, my name is JOHN and I'm 20 years old

    • D. 

      Hi, my name is JOHN and I'm 21 years old

  • 22. 
    Which of these is not a logical operator?
    • A. 

      !

    • B. 

      &

    • C. 

      &&

    • D. 

      ||

  • 23. 
    What is the value of the variable a? var a = "cat".length * 2;
    • A. 

      3

    • B. 

      6

    • C. 

      0

    • D. 

      1

  • 24. 
    What is the value of x ? var a = false; var x = a ? “A” : “B”;
    • A. 

      Undefined

    • B. 

      True

    • C. 

      "A"

    • D. 

      "B"

  • 25. 
    How would one declare a string variable?
    • A. 

      Var name = "John"

    • B. 

      Var names = "7"

    • C. 

      Var firstname = new String("John")

    • D. 

      Any of these