wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Day 3 - Dom Manipulation

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

What will be printed in the console on execution of the following JS code:

var array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15];

var myArr= array.filter(v => v % 3 === 0);


console.log(myArr);

a)

myArr

b)

[3, 6, 9, 12, 15]

c)

[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]

d)

[1, 2, 4, 5, 7, 8, 10, 11, 13, 14]

2.

What will be printed in the console on execution of the following JS code:

var array = [2, 4, 6, 7, 8, 10];

var myArr= array.filter(v => v / 2 === 0);


console.log(myArr);

a)

myArr

b)

[2, 4, 6, 7, 8, 10]

c)

[2, 4, 6, 8, 10]

d)

[7]

3.

What will be printed in the console on execution of the below code?

var materials = [

'Hydrogen',

'Helium',

'Lithium',

'Beryllium'

];


console.log(materials.map (material => material.length));

a)

[8, 6, 7, 9]

b)

4

c)

[4]

d)

8, 6, 7, 9

4.

var val = "JavaScript String"

splittedVal = val.split('a',2)

console.log(splittedVal);

a)

[ 'J', 'v' ]

b)

[ 'J' ,'v','Script']

c)

[ 'J', 'v', 'Script String' ]

d)

[ 'JavaScript String' ]

5.

Which built-in method combines the text of two strings and returns a new string?

a)

append()

b)

concat()

c)

attach()

d)

None of the above.

6.

Which of the following function of String object returns the character at the specified index?

a)

charAt()

b)

charCodeAt()

c)

concat()

d)

indexOf()

7.

The primary purpose of the array map() function is that it

a)

maps the elements of another array into itself

b)

passes each element of the array and returns the necessary mapped elements

c)

passes each element of the array on which it is invoked to the function you specify, and returns an array containing the values returned by that function

d)

None of the mentioned

8.

The method or operator used to identify the array is

a)

isarrayType()

b)

==

c)

===

d)

typeof

9.

The function definitions in JavaScript begins with

a)

Identifier and Parantheses

b)

Return type and Identifier

c)

Return type, Function keyword, Identifier and Parantheses

d)

Identifier and Return type

10.

A collection of elements of the same data type which may either in order or not, is called _____.

a)

String

b)

Array

c)

Serialized Object

d)

Object

11.

What will be the output obtained by "shift ()" in the given code of JavaScript?


var a =[]; a.unshift(5); a.unshift(22); a.shift(); a.unshift(3,[4,5]); a.shift(); a.shift(); a.shift();

a)

Exception is thrown

b)

[4,5]

c)

[3,4,5]

d)

5

12.

var values=["Three","two","one"];

var ans=values.shift();

console.log(ans);

a)

["two","one"];

b)

Three

c)

["Three","two","one"];

d)

two one

13.

var values=[4,5,6,7]

var ans=values.slice(1);

console.log(ans);

a)

[5, 6, 7]

b)

5,6,7

c)

[4,5, 6, 7]

d)

[]

14.

Javascript string using double quotes is exactly the same as a string using single quotes?

a)

True

b)

False

15.

var a = 'Java';

var b = 'Script';

var c = a/b;

console.log(c);

a)

JavaScript

b)

Java/Script

c)

NaN

d)

undefined

16.

Find output of below Javascript addition code

console.log("1 plus 1 is " + 1 + 1);

a)

2

b)

1 plus 1 is 2

c)

1 plus 1 is 11

d)

1 plus 1 is 1 + 1

17.

In JavaScript, Arrays are data type. State True or False

a)

True

b)

False

18.

If para1 is the DOM object for a paragraph, what is the correct syntax to change the text within the paragraph?

a)

para1="New Text"

b)

para1.innerText="New Text";

c)

para1.firstChild.nodeValue= "New Text";

d)

para1.nodeValue="New Text";

19.

Consider the following code snippet

const pi=3.14;

var pi=4;

console.log(pi);

What will be the output for the above code snippet?

a)

This will flash an error

b)

Prints 4

c)

Prints 3.14

d)

Ambiguity

20.

The pop() method of the array does which of the following task ?

a)

decrements the total length by 1

b)

increments the total length by 1

c)

prints the first element but no effect on the length

d)

updates the element