Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Test Your JavaScript Fundamental (Part 1)

Total questions: 25

Worksheet time: 4hrs 51mins

Name
Class
Date
1.

let yy = 10;

console.log(++yy);

console.log(yy++);

console.log(yy);

a)

11
12

10

b)

11

12

12

c)

11

12

13

d)

11
11
12

2.

let aa = "10";

console.log(aa++);

console.log(++aa);

console.log(aa);

a)

10

12

12

b)

11

12

10

c)

11

11

10

d)

undefined

3.

let s = [1, 9, 7, 100, 2, 99, 88, 20];

s.splice(2, 4, 91, 92, 93);

console.log(s);

a)

[1, 9, 91, 92, 93, 88, 20]

b)

[1, 91, 92, 93, 99, 88, 20 ]

c)

[1, 9, 7, 20, 91, 92, 93]

d)

[1, 9, 7, 91, 92 , 93, 20]

4.

const arrs = [1, 2, 3];

const { log } = console;

log(arrs.push(4));

a)

[1, 2, 3, 4]

b)

error

c)

4

d)

[1, 2 , 3]

5.

console.log(0.2 + 0.3 === 0.5);

a)

true

b)

false

c)

error

d)

NaN

6.

const arrHewan = ["ayam", `berang"`, "kambing"];

for (let i = 0; i < arrHewan.length; i++) {

console.log(arrHewan[i]);

}

a)

ayam
berang"

kambing

b)

kambing

c)

error

d)

undefined

7.


let multiply = (a, b) => a * b;

let square = (n) => multiply(n, n);

let printSquare = (n) => {

let squared = square(n);

console.log(square(n));

console.log(squared);

};

printSquare(5);

a)

25
25

b)

undefined
25

c)

25
undefined

d)

error

8.

const str = "JavaScript";

const pindah = str;

if (str === "JavaScript") {console.log(pindah, "ini if else");}

else console.log("Salah");

a)

ini if else

b)

JavaScript ini if else

c)

Salah

d)

error

9.

const baru = "new";

const baru = "baru";

console.log(baru);

a)

"baru"

b)

"new"

c)

barunew

d)

error

10.

let arr = [1,2,3,4]

let x = 2 *2;

for (let i = 0; i < 10; i++)

Big O Notation?

a)

O(1)

b)

O(n)

c)

O log n

d)

O (N^2)

11.

let sentence = "hello world";

let words = sentence.split(" ");

console.log(words);

a)

helloworld

b)

[helloworld]

c)

hello world

d)

[ 'hello' , 'world' ]

12.

const date = new Date("2023-11-21");

console.log(Date);

a)

2023-11-21

b)

[Function: Date]

c)

Tue Nov 21 2023 07:00:00 GMT+0700 (GMT+07:00)

d)

error

13.

const falsee = true;

const truee = [];

console.log(typeof falsee);

console.log(typeof truee);

Apakah jenis tipe data yang direturn oleh typeof dalam console log?

a)

string

object

b)

boolean
array

c)

boolean
object

d)

string

array

14.

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

a)

121

b)

21

c)

31

d)

1111

15.

console.log(1.5 % 0.5);

a)

0

b)

3

c)

0.5

d)

false

16.

const number = 10; //error

console.log(number % 2 == 0 ? "genap" : "ganjil");

a)

error

b)

genap

c)

ganjil

d)

false

17.

let nol = [2, 4, 6, 8, 10];

for (i = 0; i < nol.length; i++)

{console.log(nol[i]);}

a)

error

b)

0

2

4

6

8

c)

2

4

6

8

10

d)

[ ]

18.

let toRupiah = (number) => {

let num = new Intl.NumberFormat("id-ID", {

style: "currency",

currency: "IDR",

});

console.log(num.format(number).replace("IDR", "Rp "));

};

toRupiah(1000);

a)

1000

b)

[Function: toRupiah]

c)

Rp 1.000,00

d)

IDR 1000

19.

const nama = ["Budi", "Agus", "Bambang"];

const HayoApaHayo = nama.map((a) => a + " Doremi");

console.log(HayoApaHayo);

a)

[ 'Budi', 'Agus', 'Bambang']

b)

[ 'Budi', 'Agus', 'Bambang', 'Doremi']

c)

[ 'Budi', 'Agus', 'Bambang', 'a', 'Doremi']

d)

[ 'Budi Doremi', 'Agus Doremi', 'Bambang Doremi' ]

20.

const mobil = {

brand: "BMW",

model: "M4",

price: "$" + 800000,

};

console.log(mobil.model);

a)

BMW

b)

M4

c)

model: M4

d)

[ brand: "BMW", model: "M4", price: "$" + 800000]

21.

const fruit = "mangga";

switch (fruit) {

case "mangga":

console.log("ini mangga");

case "jeruk":

console.log("ini jeruk");

break;

case "salak":

console.log("ini salak");

}

a)

ini mangga

b)

ini mangga

ini jeruk

c)

ini mangga

ini jeruk

ini salak

d)

error

22.

let string = "Hello world";

const search = "ell";

console.log(string.replace(search, ""));

a)

error

b)

[ Hello', 'world']

c)

ell

d)

Ho world

23.

var num1 = 10;

var num2 = 111;

if (num1 > num2) console.log(num1);

else console.log(num2);

a)

10

b)

111

c)

error

d)

infinite loop

24.

let num = 4.01567;

console.log(num.toFixed(2))

a)

4

b)

4.01

c)

4.02

d)

4.0

25.

let arr1 = ["o", "p", "q"];

let arr2 = ["r", "s", "t"];

let split = [...arr2, ...arr1];

console.log(split);

a)

[ ['o', 'p', 'q'], ['r', 's', 't'] ]

b)

[ ['r', 's', 't'], ['o', 'p', 'q'] ]

c)

[ 'o', 'p', 'q', 'r', 's', 't' ]

d)

[ 'r', 's', 't', 'o', 'p', 'q' ]