Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

JavaScript quiz for beginners

Total questions: 10

Worksheet time: 3mins

Name
Class
Date
1.

Inside which HTML element do we put the JavaScript?

a)

<scripting>

b)

<js>

c)

<javascript>

d)

<script>

2.

What is the correct JavaScript syntax to change the content of the HTML element below?


<p id="geek">GeeksforGeeks</p>

a)

document.getElement(“geek”).innerHTML=”I am a Geek”;

b)

document.getElementById(“geek”).innerHTML=”I am a Geek”;

c)

document.getId(“geek”)=”I am a Geek”;

d)

document.getElementById(“geek”).innerHTML=I am a Geek;

3.

Which of the following is the correct syntax to display “GeeksforGeeks” in an alert box using JavaScript?

a)

alertbox(“GeeksforGeeks”);

b)

msg(“GeeksforGeeks”);

c)

msgbox(“GeeksforGeeks”);

d)

alert(“GeeksforGeeks”);

4.

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

a)

<script src=”geek.js”>

b)

<script href=”geek.js”>

c)

<script ref=”geek.js”>

d)

<script name=”geek.js”>

5.

The external JavaScript file must contain <script> tag. True or False?

a)

True

b)

False

6.

Predict the output of the following JavaScript code.

a)

16

b)

Compilation Error

c)

88

d)

Run time Error

7.

Witch intruction from this create an Loop?

a)

if

b)

while

c)

var

d)

else

8.

This date 29 is data type?

a)

Boolean

b)

String

c)

Integer

d)

Float

9.

What is the correct syntax for declaring a function?

a)

var myFunction()

b)

myFunction function()

c)

function myFunction()

d)

function my Function()

10.

Which is the correct syntax for displaying data in the console?

a)

console.log();

b)

log.console();

c)

console.log[];

d)

console.log;