
JavaScript Syntax
Quiz by Starter quizzes
Feel free to use or edit a copy
includes Teacher and Student dashboards
Measure skillsfrom any curriculum
Measure skills
from any curriculum
Tag the questions with any skills you have. Your dashboard will track each student's mastery of each skill.
With a free account, teachers can
- edit the questions
- save a copy for later
- start a class game
- automatically assign follow-up activities based on students’ scores
- assign as homework
- share a link with colleagues
- print as a bubble sheet
16 questions
Show answers
- Q1What keyword is used to declare a variable?
declare
constvarfunction30s - Q2What is the correct syntax for declaring a JavaScript variable?var = variableName;var variableName;variableName = variable;variableName = var;30s
- Q3Which statement is used to declare a constant in JavaScript?constant x = 5;const x = 5;var x = 5;let x = 5;30s
- Q4Which of the following is not a JavaScript data type?stringbooleanfloatnumber30s
- Q5What 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
- Q6What is the correct way to access the first element of an array?myArray(0)myArray[0]myArray.firstmyArray.first()30s
- Q7What is the correct way to add an element to the end of an array?myArray[myArray.length] = myElementmyArray.add(myElement)myArray.push(myElement)myArray.insert(myElement)30s
- Q8What 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 types30s
- Q9What is the correct way to write a conditional statement in JavaScript?if {} else if {}if (condition): {} else: {}if (condition) {} else {}if then {} else {}30s
- Q10What 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
- Q11What is the correct way to concatenate two strings in JavaScript?myString1 - myString2myString1 * myString2myString1 + myString2myString1 .concat(myString2)30s
- Q12What is the correct way to declare a switch statement in JavaScript?for (myVariable; myVariable.length; myVariable++) {}if (myVariable) {}myVariable.switch() {}switch (myVariable) {}30s
- Q13What is the correct way to write a function in JavaScript?function myFunction() {}myFunction() {}function = myFunction() {}function: myFunction() {}30s
- Q14How do you write an AND operator in JavaScript?
|
&&||&30s - Q15How do you write an OR operator in JavaScript?
&&
&||
|30s