Science in JavaScript Unit 1 Test
Questions and Answers Graded A+
Which keyword is used to define a variable in JavaScript?
A) constant
B) define
✔✔C) var
D) static
What is JavaScript primarily used for in web development?
✔✔A) Adding interactivity to web pages
B) Defining HTML structure
C) Styling web elements
D) Managing databases
Which of the following is a correct way to display a message in the console?
✔✔A) console.log("Hello!");
B) print("Hello!");
1
,C) alert("Hello!");
D) display("Hello!");
Which symbol is used to indicate a comment in JavaScript?
A) #
✔✔B) //
C) $$
D) @
What is the correct way to declare a function in JavaScript?
✔✔A) function myFunction() { }
B) def myFunction() { }
C) create function myFunction() { }
D) method myFunction() { }
Which of the following is NOT a valid JavaScript data type?
A) Number
✔✔B) Character
2
, C) Boolean
D) Object
Which of these is the correct syntax for an `if` statement?
✔✔A) if (x > 5) { console.log("Greater!"); }
B) if x > 5 { console.log("Greater!"); }
C) if {x > 5} console.log("Greater!");
D) if x > 5: console.log("Greater!");
What will `console.log(typeof 42);` print?
A) "boolean"
B) "string"
✔✔C) "number"
D) "object"
Which operator is used to concatenate strings in JavaScript?
✔✔A) +
B) *
3