JavaScript Worksheet: Basics
Code tip (Line by line): let x = 5; makes a variable x holding 5; x = x + 2; changes it to 7. console.log(…) writes in the console; alert(…) shows a pop-up box. Text in quotes + anything = joined text: "5" + 3 → "53".
NameDateTime takenScore ___ / 40
- 1.⚡ Which JavaScript word runs code when true? (a) console.log() (b) if (c) alert() (d) let
-
2.⚡ What does this code show?
let name = "Arjun";
console.log("Hello, " + name + "!"); (a) Arjun (b) Hello, Arjun! (c) name (d) Hello, name! - 3.⚡ Which JavaScript word makes a new variable? (a) console.log() (b) let (c) for (d) if
-
4.⚡ What number does this code print?
let a = 38;
let b = 8;
console.log(a + b); -
5.⚡ What number does this code print?
let a = 2;
let b = 6;
console.log(a * b); -
6.⚡ What does this code print? (Look at the quotes!)
let x = "2";
let y = 3;
console.log(x + y); (a) Error (b) 23 (c) 5 -
7.⚡ What number does this code print?
let a = 33;
let b = 33;
console.log(a + b); - 8.⚡ Which JavaScript word shows a pop-up box? (a) console.log() (b) alert() (c) if (d) let
- 9.⚡ What does alert() show? (a) a picture (b) a pop-up box (c) a table (d) a new tab
-
10.⚡ What number does this code print?
let score = 19;
score = score + 16;
score = score - 30;
console.log(score); -
11.⚡ What does this code show?
let name = "Riya";
console.log("Hello, " + name + "!"); (a) Riya (b) name (c) Hello, Riya! (d) Hello, name! -
12.⚡ What does this code print? (Look at the quotes!)
let x = "5";
let y = 7;
console.log(x + y); (a) Error (b) 12 (c) 57 -
13.⚡ What does this code print? (Look at the quotes!)
let x = "2";
let y = 7;
console.log(x + y); (a) 9 (b) 27 (c) Error -
14.⚡ What number does this code print?
let books = 28;
books = books + 8;
books = books - 13;
console.log(books); -
15.⚡ What does this code show?
let name = "Zoya";
alert("Hello, " + name + "!"); (a) Hello, Zoya! (b) Zoya (c) name (d) Hello, name! -
16.⚡ What does this code print? (Look at the quotes!)
let x = "7";
let y = 4;
console.log(x + y); (a) 11 (b) Error (c) 74 - 17.⚡ Which JavaScript word repeats code? (a) let (b) console.log() (c) if (d) for
-
18.⚡ What number does this code print?
let a = 36;
let b = 26;
console.log(a - b); -
19.⚡ What number does this code print?
let a = 38;
let b = 19;
console.log(a - b); -
20.⚡ What does this code show?
let name = "Kabir";
alert("Hello, " + name + "!"); (a) Kabir (b) Hello, Kabir! (c) name (d) Hello, name! - 21.⚡ Which tag holds JavaScript in a page? (a) <style> (b) <code> (c) <script> (d) <js>
-
22.⚡ What does this code show?
let name = "Zoya";
alert("Well done, " + name + "!"); (a) name (b) Well done, Zoya! (c) Zoya (d) Well done, name! - 23.⚡ Which word makes a new variable? (a) make (b) let (c) give (d) put
-
24.⚡ What does this code print? (Look at the quotes!)
let x = "4";
let y = 4;
console.log(x + y); (a) 44 (b) Error (c) 8 -
25.⚡ What number does this code print?
let a = 34;
let b = 24;
console.log(a + b); -
26.⚡ What number does this code print?
let score = 21;
score = score + 14;
score = score - 14;
console.log(score); -
27.⚡ What number does this code print?
let books = 10;
books = books + 14;
books = books - 23;
console.log(books); - 28.⚡ A JavaScript file usually ends with which extension? (a) .css (b) .js (c) .html (d) .jpg
-
29.⚡ What number does this code print?
let a = 59;
let b = 9;
console.log(a - b); -
30.⚡ What does this code show?
let name = "Aman";
console.log("Well done, " + name + "!"); (a) Well done, name! (b) name (c) Well done, Aman! (d) Aman -
31.⚡ What number does this code print?
let a = 32;
let b = 16;
console.log(a - b); -
32.⚡ What number does this code print?
let books = 29;
books = books + 17;
books = books - 46;
console.log(books); - 33.⚡ Where does console.log() show its output? (a) on the printer (b) in the address bar (c) on the title bar (d) in the console
-
34.⚡ What number does this code print?
let a = 2;
let b = 2;
console.log(a * b); -
35.⚡ What does this code show?
let name = "Meera";
alert("Hello, " + name + "!"); (a) name (b) Hello, name! (c) Meera (d) Hello, Meera! -
36.⚡ What number does this code print?
let coins = 27;
coins = coins + 5;
coins = coins - 32;
console.log(coins); -
37.⚡ What does this code print? (Look at the quotes!)
let x = "3";
let y = 3;
console.log(x + y); (a) 33 (b) 6 (c) Error -
38.⚡ What number does this code print?
let a = 58;
let b = 40;
console.log(a - b); -
39.⚡ What number does this code print?
let a = 42;
let b = 31;
console.log(a - b); -
40.⚡ What does this code show?
let name = "Aman";
alert("Well done, " + name + "!"); (a) Well done, name! (b) Well done, Aman! (c) name (d) Aman
Answer key
- if
- Hello, Arjun!
- let
- 46
- 12
- 23
- 66
- alert()
- a pop-up box
- 5
- Hello, Riya!
- 57
- 27
- 23
- Hello, Zoya!
- 74
- for
- 10
- 19
- Hello, Kabir!
- <script>
- Well done, Zoya!
- let
- 44
- 58
- 21
- 1
- .js
- 50
- Well done, Aman!
- 16
- 0
- in the console
- 4
- Hello, Meera!
- 0
- 33
- 18
- 11
- Well done, Aman!
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids