wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

HTML Basics Quiz

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

Which is the correct way to write inline JavaScript?

a)

<script> alert("Hi") </script>

b)

<button onclick="alert('Hi')">Click</button>

c)

<script src="app.js"></script>

d)

alert('Hi')

2.

Which tag is used for internal JavaScript?

a)

<javascript>

b)

<script>

c)

<js>

d)

<style>

3.

External JavaScript file must have which extension?

a)

.js

b)

.css

c)

.html

d)

.py

4.

How do you declare a variable in JavaScript?

a)

variable x;

b)

var x;

c)

define x;

d)

int x;

5.

Which statement accesses an element by id?

a)
b)

document.getElement("id")

c)

document.getElementById()

6.

Which event occurs when a user clicks?

a)

onpress

b)

onclick

c)

onmouse

d)

clickdo

7.

How to write a function in JS?

a)

function myFunc() { }

b)

def myFunc() { }

c)

func = myFunc() { }

d)

create myFunc() { }

8.

Which operator is used for AND?

a)

&

b)

||

c)

!

d)

&&

9.

Which operator is used for OR?

a)

&&

b)

||

c)

!

d)

&

10.

Which string method returns length?

a)

size()

b)

len()

c)

length

d)

count()

11.

DOM stands for?

a)

Document Output Model

b)

Direct Object Manipulation

c)

Document Object Model

d)

Data Object Model

12.

To add a class using JS:

a)

el.addClass("red")

b)

el.classList.add("red")

c)

el.class.add("red")

d)

add.class("red")

13.

To remove a class:

a)

el.remove("red")

b)

el.classList.remove("red")

c)

el.class.remove("red")

d)

el.deleteClass("red")

14.

Which one is NOT a loop?

a)

for

b)

while

c)

repeat

d)

do while

15.

To stop a loop:

a)

break

b)

finish

c)

stop

d)

end

16.

Which symbol is used for single-line comments in JavaScript?

a)

#

b)

//

c)

/*/

d)

--

17.

Which function is used to print output to console?

a)

print()

b)

console.write()

c)

log()

d)

console.log()

18.

Which string method converts to uppercase?

a)

upper()

b)

toUpper()

c)

toUpperCase()

d)

makeUpper()

19.

Which operator is used to check NOT equal?

a)

=/=

b)

!=

c)

<>

d)

!==

20.

Which creates a paragraph element using DOM?

a)

document.create("p")

b)

document.newElement("p")

c)

new Element("p")

d)

document.createElement("p")