placeholder image to represent content

JavaScript Syntax

Quiz by Starter quizzes

Our brand new solo games combine with your quiz, on the same screen

Correct quiz answers unlock more play!

New Quizalize solo game modes
16 questions
Show answers
  • Q1
    What keyword is used to declare a variable?

    declare

    const
    var
    function
    30s
  • Q2
    What is the correct syntax for declaring a JavaScript variable?
    var = variableName;
    var variableName;
    variableName = variable;
    variableName = var;
    30s
  • Q3
    Which statement is used to declare a constant in JavaScript?
    constant x = 5;
    const x = 5;
    var x = 5;
    let x = 5;
    30s
  • Q4
    Which of the following is not a JavaScript data type?
    string
    boolean
    float
    number
    30s
  • Q5
    What is the correct way to write a comment in JavaScript?
    / This is a comment
    // This is a comment
    /* This is a comment */
    <!-- This is a comment -->
    30s
  • Q6
    What is the correct way to access the first element of an array?
    myArray(0)
    myArray[0]
    myArray.first
    myArray.first()
    30s
  • Q7
    What is the correct way to add an element to the end of an array?
    myArray[myArray.length] = myElement
    myArray.add(myElement)
    myArray.push(myElement)
    myArray.insert(myElement)
    30s
  • Q8
    What is the difference between == and === in JavaScript?
    == compares values, while === compares values and types
    == and === are equivalent
    == compares types, while === compares values and types
    == compares memory locations, while === compares values and types
    30s
  • Q9
    What is the correct way to write a conditional statement in JavaScript?
    if {} else if {}
    if (condition): {} else: {}
    if (condition) {} else {}
    if then {} else {}
    30s
  • Q10
    What is the correct way to loop through an array in JavaScript?
    foreach (myArray as i) {}
    for (var i = 0; i < myArray.length; i++) {}
    while (i < myArray.length) {}
    for (var i = 1; i <= myArray.length; i++) {}
    30s
  • Q11
    What is the correct way to concatenate two strings in JavaScript?
    myString1 - myString2
    myString1 * myString2
    myString1 + myString2
    myString1 .concat(myString2)
    30s
  • Q12
    What is the correct way to declare a switch statement in JavaScript?
    for (myVariable; myVariable.length; myVariable++) {}
    if (myVariable) {}
    myVariable.switch() {}
    switch (myVariable) {}
    30s
  • Q13
    What is the correct way to write a function in JavaScript?
    function myFunction() {}
    myFunction() {}
    function = myFunction() {}
    function: myFunction() {}
    30s
  • Q14
    How do you write an AND operator in JavaScript?

    |

    &&
    ||
    &
    30s
  • Q15
    How do you write an OR operator in JavaScript?

    &&

    &

    ||

    |
    30s

Teachers give this quiz to your class