wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Javascript HTML CSS

Total questions: 13

Worksheet time: 14mins

Name
Class
Date
1.

The output of the below code is:


<p id="demo"></p>


<script>

var text = "";

var i;

for (i = 0; i < 5; i++) {

text += "The number is " + i + "<br>";

}

document.getElementById("demo").innerHTML = text;

</script>

a)

The number is 0

The number is 1

The number is 2

The number is 3

The number is 4

The number is 5

b)

The number is 0

The number is 1

The number is 2

The number is 3

The number is 4

c)

The number is 1

The number is 2

The number is 3

The number is 4

The number is 5

d)

Why is that person using "var"???

2.

What is the difference between == and ===?

a)

The === operator compares two values, without taking into account their types. == compares the values, but also makes their types into account.

b)

Do I really need to reply this?

c)

The == operator compares two values, without taking into account their types. === compares the values, but also makes their types into account.

d)

The == operator is used to assign a value to a variable. === is used to compare the values of two variables.

3.

What is the DOM?

a)

Is an open standard file format, and data interchange format, that uses human-readable text to store and transmit data objects consisting of attribute–value pairs and array data types

b)

Is the standard markup language for documents designed to be displayed in a web browser. It can be assisted by technologies such as Cascading Style Sheets (CSS) and scripting languages such as JavaScript

c)

Is a markup language that defines a set of rules for encoding documents in a format that is both human-readable and machine-readable

d)

The Document Object Model is a cross-platform and language-independent interface that treats an XML or HTML document as a tree structure wherein each node is an object representing a part of the document

4.

What are the Javascript data types?

a)

There are seven data types: Boolean, Null, Undefined, Number, String, Symbol, Object.

b)

There are eighth data types: Boolean, Null, Undefined, Number, String, Symbol, Object, Date.

c)

There are nine data types: Boolean, Null, Undefined, Number, String, Symbol, Object, Date, JSON.

d)

Sorry, what do you mean by data type?

5.

What are the pop-up boxes types available in JavaScript?

a)

Alert, Redirect and Prompt

b)

Alert, Confirm and Prompt

c)

Nice try, a pop-up can be done only using jquery or a similar library

d)

Alert, Confirm, Redirect and Prompt

6.

Which image best describes the meaning of null and undefined?

a)
b)
c)
d)
7.

What are HTML Tags?

a)

HTML tags are composed of three things: an opening tag, content and ending tag. Some tags are unclosed tags.

b)

HTML tags are composed of three things: an opening tag, content and ending tag. All tags need to be closed.

c)

HTML tags define metadata about an HTML document. Metadata is data (information) about data.

d)

I didn't know that I was supposed to be studying

8.

What is the use of the required attribute in HTML5?

Name: <input type="text" name="name" required>

a)

This adds a red border over the input box for the user to visually recognize that it is required.

b)

It forces a user to fill text on the text field or text area before submitting the form. It is used for form validation. But, the "required" attribute is not properly written in this example.

c)

It would be nice to have that functionality, but due to browser compatibility it does not work and manual validation is required.

d)

It forces a user to fill text on the text field or text area before submitting the form. It is used for form validation.

9.

What are the new <input> types for form validation in HTML5?

a)

The new input types for form validation are text, textarea, radio, email, URL, number, tel, and date.

b)

The new input types for form validation are text, area, radio, email, URL, number, tel, and date.

c)

The new input types for form validation are email, URL, number, tel, and date.

d)

All these options are available since previous versions of HTML.

10.

How to write HTML code dynamically using JavaScript?

a)

document.getElementById('some-div-id').innerHTML="<h2>This is heading using JavaScript</h2>";

b)

document.getElementById('some-div-id').innerHTML.val("<h2>This is heading using JavaScript</h2>";)

c)

document.getElementById('some-div-id').innerHTML.html("<h2>This is heading using JavaScript</h2>";)

d)

document.getElementByTagName('some-div-id').innerHTML="<h2>This is heading using JavaScript</h2>";

11.

What is the output of 10+20+"30" in JavaScript?

a)

102030 because since there is a string, all the + will be treated as string concatenation operator (not binary +).

b)

102030 because before you perform arithmetic operations you would have to explicitly convert those values to an actual number.

c)

That will throw an unhandled exception, a try catch block is required to prevent it.

d)

3030 because 10+20 will be 30. If there is numeric value before and after +, it treats as binary + (arithmetic operator).

12.

How to submit a form using JavaScript by clicking a link?

a)

<form name="myform">

<a href="javascript: document.myform.submit();">Submit</a>

</form>

b)

<form name="myform">

<button type="button" onclick="javascript: document.myform.submit();">Click Me!</button>

</form>

c)

<form name="myform">

<input type="submit" value="Submit">

</form>

d)

<form name="myform">

<span id="link" onclick="javascript: document.myform.submit();"></span>

</form>

13.

Select the correct option:

a)

The getElementsByName() method returns a live HTMLCollection of elements with the given tag name.

The getElementsByTagName() method returns a collection of all elements in the document with the specified name (the value of the name attribute), as an HTMLCollection object.

b)

The innerHTML property sets or returns the text content of the specified node, and all its descendants.

The innerText property sets or returns the HTML content of an element.

c)

let allows you to declare variables that are limited to the scope of a block statement, or expression on which it is used, unlike the var keyword, which declares a variable globally, or locally to an entire function regardless of block scope

d)

The difference between POST and PUT is that POST requests are idempotent. That is, calling the same POST request multiple times will always produce the same result. In contrast, calling a PUT request repeatedly have side effects of creating the same resource multiple times.