JavaScript Pre Kt Assessment

10 Questions | Attempts: 428
Share

SettingsSettingsSettings
JavaScript Quizzes & Trivia

This quiz will test the very basic JS knowledge. If you have gone through w3 schools website, this should be a very easy quiz. Have fun!


Questions and Answers
  • 1. 
    How do you create a function named coolFunction?
    • A. 

      Function coolfunction () {}

    • B. 

      Function=coolFunction();

    • C. 

      Function:coolFunction(){}

    • D. 

      Function coolFunction () {}

  • 2. 
    An alert box is very useful for debugging. To display text ‘’message’ along with the value contained in variable msg, an alert box should be called via: 
    • A. 

      Call alert ('message' + msg);

    • B. 

      Alert ('message' + msg);

    • C. 

      AlertBox ('message' + msg);

    • D. 

      All of the above

  • 3. 
    In a JS statement, what is the difference between a++  vs ++a where a is a variable:
    • A. 

      A++ increments the value of a by 1, ++a is incorrect

    • B. 

      Both are same and increment the value of a by 1

    • C. 

      Both increments the value of a by 1 but a++ does it after assignment and ++a does it before assignment

    • D. 

      Both are wrong and will cause an error in the code

  • 4. 
      - Which of these is not a comparison operator?
    • A. 

    • B. 

      >

    • C. 

      =

    • D. 

      !=

  • 5. 
    Which command skips the rest of a case statement ?
    • A. 

      Return

    • B. 

      Exit

    • C. 

      Continue

    • D. 

      Break

  • 6. 
    How can you reference part of a string starting from 4th character and containing a total of 5 characters contained in var str? (e.g. from a string “hello world!”, it should return “lo wo”).
    • A. 

      Str.substr(4,9);

    • B. 

      Str.part(3,5);

    • C. 

      Str.substr(3,5);

    • D. 

      Str.part(4,9);

  • 7. 
    Which event do you use to run something after the page has finished loading?
    • A. 

      Onfinished

    • B. 

      Onload

    • C. 

      Onunload

    • D. 

      Oncomplete

  • 8. 
    How do you define a "for" loop which starts from 0, goes till 5 and increments by 1 after each iteration?
    • A. 

      For (i

    • B. 

      For i = 0 to 5 {…}

    • C. 

      For (i = 0; i

    • D. 

      For (i = 0; i

  • 9. 
    What is the correct way to write a JavaScript array?
    • A. 

      Var txt = new Array ="tim","kim","jim";

    • B. 

      Var txt = new Array("tim","kim","jim");

    • C. 

      Var txt = new Array:1=("tim")2=("kim")3=("jim");

    • D. 

      Var txt = new Array(1:"tim",2:"kim",3:"jim");

  • 10. 
    What will the statement mentioned below will do?result =  (testCond == 1) ? “pass” : “fail”;
    • A. 

      Will return error as this is not a valid statement in JS.

    • B. 

      If testCond is equal to 1 then result will contain an array with two elements pass and fail.

    • C. 

      If testCond is equal to 1 then result will contain string pass otherwise it will be set to fail.

    • D. 

      Result will contain value of testCond if the testCond is equal to 1

Back to Top Back to top
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.