wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

JavaScripting

Total questions: 10

Worksheet time: 2mins

Name
Class
Date
1.

What is the correct syntax for referring to an external script “index.js” ?

a)

<script name=”index.js”>

b)

<script href=”index.js”>

c)

<noscript src=”index.js”>

d)

<script src=”index.js”>

2.

Which of the following is not a keyword used to define a variable in ES6?

a)

var

b)

val

c)

const

d)

let

3.

Which of the following lines of code can remove the class “nav” from the following element:


<div><div class=”nav”>Hello</div></div>

a)

document.getElementByClass(“nav”).classList.remove(“nav”)

b)

document.getElementById(“div”).removeClass(“nav”)

c)

document.querySelectorAll(“div”).classList.remove(“nav”)

d)

document.querySelector(“div”).removeClass(“nav”)

4.

Which of the following is not valid when creating a function in JavaScript ?

a)

function ( ) => { }

b)

function functionName( ) = { }

c)

function functionName( ) { }

d)

const myFunction = functionName( ) { }

5.

How can one get an attribute “attr” of an element <foo> ?

a)

foo.attributes[0]

b)

foo.attr

c)

foo.attributes.attr

d)

None of the above

6.

How will you return an element with id=”first” ?

a)

document.getElementById(“first”)

b)

document.querySelector(“#first”)

c)

document.querySelector(“.first”)

d)

A and B both

e)

A and C both

7.

How will you change the content inside an element <foo> to the text “Hello World” ?

a)

foo.innerHTML = “Hello World”

b)

foo.innerContent = “Hello World”

c)

foo.innerText = “Hello World”

d)

A and C both

e)

B and C both

8.

Which of the following allows you to call a function based on an elapsed time ?

a)

setElapsedTime( )

b)

setInterval( )

c)

setTimeout( )

d)

setCountDown( )

9.

Which event occurs when the user clicks on an HTML element using a mouse ?

a)

onMouseOver

b)

onChange

c)

onClick

d)

onMouseClick

10.

Which of the following is opposite to an onMouseOver event ?

a)

onMouseOff

b)

onMouseOut

c)

onMouseUnder

d)

None of the above