Which of the following is a valid way to declare a variable in JavaScript?

AP Computer Science Principles Pre-Test

Quiz
•
Information Technology (IT)
•
10th Grade
•
Medium
Ethan Batres
Used 4+ times
FREE Resource
30 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
`var myVariable;`
`variable myVariable;`
`declare myVariable;`
`int myVariable;`
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be the output of the following code snippet?
var x = 5;
var y = 10;
console.log(x + y);
15
510
5
10
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following is a function declaration in JavaScript?
`function myFunction() {}`
`let myFunction = function() {}`
`const myFunction = () => {}`
`myFunction() = function() {}`
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the scope of a variable declared with `var` inside a function?
Global
Local to the function
Local to the block
Local to the script
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Consider the following code:
function add(a, b) {
return a + b;
}
What will `add(3, 4)` return?
34
7
12
undefined
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following is a valid way to create a list (array) in JavaScript?
`var myList = {};`
`var myList = [];`
`let myList = ();`
`let myList = <>;`
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be the output of the following code?
var fruits = ['apple', 'banana', 'cherry'];
console.log(fruits[1]);
apple
banana
cherry
undefined
Create a free account and access millions of resources
Similar Resources on Quizizz
30 questions
EVALUASI TENGAH SEMESTER GENAP

Quiz
•
10th Grade - University
30 questions
Form 4 - CSEC Information Technology Quiz

Quiz
•
10th Grade - University
31 questions
Python for Beginners Quiz (Grok Academy Modules 1-10)

Quiz
•
10th Grade
25 questions
G9-Introduction to Python Programming

Quiz
•
9th Grade - University
25 questions
Exame de Módulo (Ambiente de Desenvolvimento)

Quiz
•
9th - 12th Grade
25 questions
Kuis Tambahan Python

Quiz
•
9th - 12th Grade
29 questions
Mod 2 Risk Adversity Trust

Quiz
•
9th - 12th Grade
25 questions
Code HS Computer SCi 114.1.1 JavaScript Final Exam Pt. 1

Quiz
•
9th - 12th Grade
Popular Resources on Quizizz
15 questions
Character Analysis

Quiz
•
4th Grade
17 questions
Chapter 12 - Doing the Right Thing

Quiz
•
9th - 12th Grade
10 questions
American Flag

Quiz
•
1st - 2nd Grade
20 questions
Reading Comprehension

Quiz
•
5th Grade
30 questions
Linear Inequalities

Quiz
•
9th - 12th Grade
20 questions
Types of Credit

Quiz
•
9th - 12th Grade
18 questions
Full S.T.E.A.M. Ahead Summer Academy Pre-Test 24-25

Quiz
•
5th Grade
14 questions
Misplaced and Dangling Modifiers

Quiz
•
6th - 8th Grade
Discover more resources for Information Technology (IT)
17 questions
Chapter 12 - Doing the Right Thing

Quiz
•
9th - 12th Grade
20 questions
Types of Credit

Quiz
•
9th - 12th Grade
30 questions
Linear Inequalities

Quiz
•
9th - 12th Grade
20 questions
Taxes

Quiz
•
9th - 12th Grade
17 questions
Parts of Speech

Quiz
•
7th - 12th Grade
20 questions
Chapter 3 - Making a Good Impression

Quiz
•
9th - 12th Grade
20 questions
Inequalities Graphing

Quiz
•
9th - 12th Grade
10 questions
Identifying equations

Quiz
•
KG - University