Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

JavaScript Essentials 1 | JSE1 – Final Test Exam

Total questions: 30

Worksheet time: 15mins

Name
Class
Date
1.

Entering about:blank in the address bar of your browser will:

a)
  • open a tab with information about your browser.

b)
  • clear all inputs on the current page.

c)
  • generate a page with information about the browser’s status.

d)

generate and load a minimal blank HTML page into the current tab.

2.

Analyze the following code:

let id = "100";
{
let id = 200;
id = id + 1; console.log(id);
}
What will appear to the console as a result?

a)
  • 1001

b)
  • 101

c)
  • 201

d)

200

3.

Select a set of data types, containing only complex types:

a)
  • Object, String

b)
  • Boolean, Number, Bigint

c)
  • Array, Object

d)

Array, Object, String

4.

We can replace the declaration let x = 3e-3; with:

a)
  • let x = 3000;

b)
  • let x = 0.003;

c)
  • let x = 0.0003;

d)

let x = 0.333;

5.

Using the string interpolation technique, we can create the string:

"I do not like travelling by plane"

and store it in the msg variable using the command:

a)
  • let means = "plane"; let msg = 'I do not like travelling by \{ means \}';

b)
  • let means = "plane"; let msg = "I do not like travelling by ${ means }";

c)
  • let means = "plane"; let msg = `I do not like travelling by ${means}`;

d)
  • let means = "plane"; let msg = `I do not like travelling by {means}`;

6.

We declare a movie object, with two fields: title and year:

let movie = {
title: "Life",
year: 1999

To change the value of the title field to "Matrix" we need to perform:

a)
  • movie[title] = "Matrix";

b)
  • movie.title = "Matrix";

c)
  • movie{title} = "Matrix";

d)

title->movie = "Matrix";

7.

You declare the following array of animals: let animals = ["canary", "dog", "cat"];. Then, you call the method animals.push("hamster");. What will the animals array look like after calling the method?

a)
  • ["canary", "dog", "cat", "hamster"]

b)
  • ["hamster"]

c)
  • ["hamster", "canary", "dog", "cat"]

d)
  • ["canary", "dog", "cat"]

8.

A JavaScript code includes the console.log("http://somethingNew.org"); command. Its execution will:

a)
b)
c)
d)
9.

Analyze the code snippet:

let winter = ["December", "January", "February"]; let index = winter.indexOf("February");

What value will the index variable have?

a)
  • "February"

b)
  • 2

c)
  • 3

d)

1

10.

In the daysOfWeek variable, you place an array with the names of the days of the week. Which method will you call to reverse the order of the array elements.

a)
  • daysOfWeek.invert();

b)
  • daysOfWeek = reverse(daysOfWeek);

c)
  • daysOfWeek.reverse();

d)
  • daysOfWeek.order(-1);

11.

Review the following code:

let msg1 = 'hello'; let msg2 = msg1.slice(-1); console.log(msg2 ? msg2 : msg2 + msg1);

What will appear on the console as a result?

a)
  • o

b)
  • ohello


c)
  • hello

d)
  • h

12.

Analyze the following code:

let test = prompt("Run", "code");

What value will the test variable have if, after running the code, we immediately press the OK button on the newly created dialog?

a)
  • true

b)
  • OK

c)
  • code

d)
  • Run

13.

Analyze the following code:

let x = false || true;
let y = "true" && "false";

let z = false && true;

console.log(`${x} ${y} ${z}`);

What will appear in the console as a result of its execution?

a)
  • false true true

b)
  • false false false

c)
  • false false true

d)
  • true false false

14.

Analyze the following code:

let a = true && 20;

let b = 0 || 20;

let c = 0 && 20;

console.log(`${a} ${b} ${c}`);

What will appear in the console as a result of its execution?

a)
  • true 20 0

b)
  • 1 1 0

c)
  • true true false

d)
  • 20 20 0

15.

Examine the following code:

let a = 20 + "10";

let b = 20 + +"10";

let c = 20 + -"10" + "10";

let d = "10" - "10" + "100";

let e = "A" - "B" + 0xA; console.log(`${a}, ${b}, ${c}, ${d}, ${e}`);

What will appear on the console as a result?

a)
  • 30, 30, 20, 100, 2

b)
  • 30, 31, 39, 100, NaN

c)
  • 2010, 2010, 20-1010, 0100, NaN

d)
  • 2010, 30, 1010, 0100, NaN

16.

Which of the following loop instructions checks the loop continuation condition only after the iteration has been completed?

a)
  • for ... in

b)
  • while

c)
  • for

d)
  • do ... while

17.

The following function using a function expression has been defined:

let sum = function (a, b) {    

return (a + b); }

What could the definition of the corresponding arrow function look like?

a)
  • let sum = function (a, b) => { return (a + b); }

b)
  • let sum = (a, b) => a + b;

c)
  • let sum = (a, b) => { a + b; };

d)
  • let sum = (a, b)-- > a + b;

18.

The temp array contains air temperature data measured over a period of time. You want to display the minimal temperature using the following code:

temp.forEach(e => min = min > e ? e : min);

console.log(min);

What should the declaration of the min variable look like?

a)
  • let min;

b)
  • It’s not necessary, as it will be declared automatically on first use.

c)
  • let min = temp[0];

d)
  • let min = 0;

19.

Examine the following code:

let x = [10, 20, 30, 40]; let y = [50, 60];

x.reverse().push(y);

console.log(x.length);

What will appear on the console as a result?

a)

6

b)

4

c)

5

d)

2

20.

Analyze the following code:

for(let a=1; a<10; a+=2) {    

console.log(a); };

Which statement can replace the for from the example?
VSECHNY ODPOVEDI JSOU REALNE SPATNE NEVIM PROC TO TAM TAKHLE JE ZADANY

a)
  • let counter = 1; while (counter++ < 10) console.log(counter++);

b)
  • let counter = 0; while (counter < 9) console.log(counter++);

c)
  • let counter = 0; while (counter++ < 10) console.log(counter++);

d)
  • let counter = 0; while (counter < 10) console.log(counter++);

21.

Analyze the following code:

let colors = ['red', 'green', 'blue'];

for (let c of colors) console.log(c);

What will appear on the console as a result?

a)
  • ['red', 'green', 'blue']

b)
  • red green blue

c)
  • 0 1 2

d)
  • 3

22.

Analyze the following code:

let route = {distance: 131, elevation: 1.4};

for (let k in route) console.log(k);

What will appear on the console as a result?

a)
  • 131 1.4

b)
  • distance

c)
  • distance elevation

d)
  • 2

23.

Examine the following code:

let a = (n) => {    

return n > 2 ? n * a(n - 1) : 2

}

console.log(a(6));

What will appear on the console as a result?

a)
  • 120

b)
  • 720

c)
  • 6

d)

4

24.

Examine the following code:

let x = mult(2)(10);

console.log(x); // -> 20

What should the mult function declaration look like if the execution of this code results in a value of 20 in the console?

a)
  • let mult = function (a) { return function (b) { return a * b; } }

b)
  • There is an error in the code and it is not possible to declare such a function correctly.

c)
  • let mult = function (a, b) { return a * b; }

d)
  • let mult = function (a, b) { return b ? mult(b) : mult(a); }

25.

Analyze the code snippet:

let counter = 0;

let userName = "John";

After declaring the counter variable, we want to add a short comment with information about what the variable is used for. To do this, we modify the line with the declaration to the form:

a)
  • // let counter = 0; user visit counter

b)
  • let counter = 0; // user visit counter

c)
  • let counter = 0; ;;user visit counter

d)

let counter = 0; /* user visit counter

26.

Examine the following code:

x = [40, 10, 30, 20, 50];

x.sort(cmp);

How should the function cmp be declared if, after the code execution, the elements of the array x are sorted in ascending order?

a)
  • let cmp = (a, b) => b < a;

b)
  • let cmp = (a, b) => a - b;

c)
  • let cmp = (a, b) => b > a;

d)

let cmp = (a, b) => b - a;

27.

Analyze the following code, which is missing one line:

let counter = 2;

let interval = setInterval(() => {    

console.log(counter);

// Insert missing line here.

}, 1000);

What should the missing line look like if the execution of this code results in the console displaying the values 2, 1, and 0 in sequence?

a)
  • if (counter-- >= 0) clearInterval(interval);

b)
  • if (counter-- <= 0) clearInterval(interval);

c)
  • while (counter-- >= 0) clearInterval(interval);

d)

clearInterval(interval);

28.

Analyze the following code:

function execute(todo, a, b) {

return todo(a, b);

}

console.log(execute(power, 3, 2));

Before declaring the function, we should add one more line of code. Which one, if the execution of the completed code will result in the console displaying the value 9?

a)
  • let power = () => a ** b;

b)
  • let power = 9;

c)
  • let power = (x,y) => x * y;

d)

let power = (x, y) => x ** y;

29.

Analyze the following code:

const a = "hello";    

console.log(a.toUpperCase()); } } catch (error) {    

console.log(a) } finally {    

console.log(a); }

What will happen as a result of its execution?

a)
  • The following words will appear in the console on subsequent lines: HELLO, hello, and hello.

b)
  • The following words will appear in the console on subsequent lines: HELLO and hello.

c)
  • The following words will appear in the console on subsequent lines: hello and hello.

d)

The following word will appear in the console: HELLO.

30.

Placing a debugger; statement in the program code will:

a)
  • stop the program without the ability to continue, as long as the execution environment supports “debugging functionality”.

b)
  • pause the program with the ability to continue, as long as the execution environment supports “debugging functionality”.

c)
  • put the interpreter into report mode, which will cause the console to print out all sequentially executed commands.

d)

cause the console to display the completion status of the statement preceding the debugger.