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.⚡ What number does this code print?
let a = 3;
let b = 7;
console.log(a * b); - 2.⚡ Which JavaScript word repeats code? (a) alert() (b) for (c) if (d) console.log()
-
3.⚡ What number does this code print?
let a = 10;
let b = 3;
console.log(a * b); - 4.⚡ Which JavaScript word makes a new variable? (a) console.log() (b) if (c) for (d) let
- 5.⚡ Which JavaScript word writes in the console? (a) alert() (b) for (c) console.log() (d) if
-
6.⚡ What does this code show?
let name = "Kabir";
alert("Hello, " + name + "!"); (a) name (b) Hello, Kabir! (c) Kabir (d) Hello, name! -
7.⚡ What does this code print? (Look at the quotes!)
let x = "6";
let y = 8;
console.log(x + y); (a) 14 (b) 68 (c) Error -
8.⚡ What number does this code print?
let a = 22;
let b = 25;
console.log(a + b); -
9.⚡ What number does this code print?
let marks = 25;
marks = marks + 17;
marks = marks - 2;
console.log(marks); - 10.⚡ Which JavaScript word runs code when true? (a) for (b) let (c) console.log() (d) if
-
11.⚡ What number does this code print?
let a = 35;
let b = 9;
console.log(a + b); -
12.⚡ What number does this code print?
let coins = 18;
coins = coins + 4;
coins = coins - 22;
console.log(coins); - 13.⚡ Which tag holds JavaScript in a page? (a) <style> (b) <js> (c) <script> (d) <code>
-
14.⚡ What does this code print? (Look at the quotes!)
let x = "9";
let y = 9;
console.log(x + y); (a) 99 (b) Error (c) 18 -
15.⚡ What does this code show?
let name = "Zoya";
alert("Welcome, " + name + "!"); (a) Welcome, name! (b) name (c) Welcome, Zoya! (d) Zoya -
16.⚡ What number does this code print?
let coins = 12;
coins = coins + 14;
coins = coins - 23;
console.log(coins); -
17.⚡ What does this code print? (Look at the quotes!)
let x = "9";
let y = 2;
console.log(x + y); (a) 11 (b) 92 (c) Error -
18.⚡ What does this code print? (Look at the quotes!)
let x = "5";
let y = 5;
console.log(x + y); (a) 55 (b) 10 (c) Error -
19.⚡ What number does this code print?
let marks = 5;
marks = marks + 8;
marks = marks - 7;
console.log(marks); -
20.⚡ What does this code show?
let name = "Riya";
alert("Well done, " + name + "!"); (a) Well done, name! (b) Riya (c) Well done, Riya! (d) name -
21.⚡ What number does this code print?
let marks = 22;
marks = marks + 15;
marks = marks - 6;
console.log(marks); - 22.⚡ 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
-
23.⚡ What number does this code print?
let books = 20;
books = books + 9;
books = books - 2;
console.log(books); -
24.⚡ What does this code print? (Look at the quotes!)
let x = "4";
let y = 7;
console.log(x + y); (a) Error (b) 11 (c) 47 -
25.⚡ What does this code print? (Look at the quotes!)
let x = "1";
let y = 2;
console.log(x + y); (a) Error (b) 3 (c) 12 - 26.⚡ Which JavaScript word shows a pop-up box? (a) if (b) let (c) alert() (d) console.log()
- 27.⚡ Which word makes a new variable? (a) give (b) let (c) put (d) make
- 28.⚡ A JavaScript file usually ends with which extension? (a) .jpg (b) .js (c) .html (d) .css
-
29.⚡ What number does this code print?
let score = 6;
score = score + 8;
score = score - 1;
console.log(score); -
30.⚡ What does this code print? (Look at the quotes!)
let x = "1";
let y = 4;
console.log(x + y); (a) Error (b) 5 (c) 14 -
31.⚡ What number does this code print?
let apples = 7;
apples = apples + 6;
apples = apples - 2;
console.log(apples); -
32.⚡ What number does this code print?
let a = 12;
let b = 3;
console.log(a * b); -
33.⚡ What number does this code print?
let a = 12;
let b = 9;
console.log(a * b); -
34.⚡ What number does this code print?
let a = 10;
let b = 2;
console.log(a * b); -
35.⚡ What does this code show?
let name = "Arjun";
console.log("Well done, " + name + "!"); (a) Well done, name! (b) Arjun (c) name (d) Well done, Arjun! -
36.⚡ What does this code show?
let name = "Meera";
console.log("Hello, " + name + "!"); (a) Hello, Meera! (b) Hello, name! (c) name (d) Meera -
37.⚡ What number does this code print?
let a = 7;
let b = 17;
console.log(a + b); -
38.⚡ What number does this code print?
let books = 9;
books = books + 7;
books = books - 13;
console.log(books); -
39.⚡ What number does this code print?
let a = 2;
let b = 2;
console.log(a * b); -
40.⚡ What does this code print? (Look at the quotes!)
let x = "3";
let y = 9;
console.log(x + y); (a) 12 (b) Error (c) 39
Answer key
- 21
- for
- 30
- let
- console.log()
- Hello, Kabir!
- 68
- 47
- 40
- if
- 44
- 0
- <script>
- 99
- Welcome, Zoya!
- 3
- 92
- 55
- 6
- Well done, Riya!
- 31
- in the console
- 27
- 47
- 12
- alert()
- let
- .js
- 13
- 14
- 11
- 36
- 108
- 20
- Well done, Arjun!
- Hello, Meera!
- 24
- 3
- 4
- 39
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids