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 apples = 11;
apples = apples + 5;
apples = apples - 13;
console.log(apples); -
2.⚡ What number does this code print?
let a = 8;
let b = 4;
console.log(a * b); -
3.⚡ What number does this code print?
let marks = 11;
marks = marks + 4;
marks = marks - 2;
console.log(marks); - 4.⚡ Which JavaScript word runs code when true? (a) let (b) console.log() (c) if (d) for
-
5.⚡ What number does this code print?
let a = 48;
let b = 26;
console.log(a + b); -
6.⚡ What number does this code print?
let a = 17;
let b = 4;
console.log(a + b); - 7.⚡ What does alert() show? (a) a new tab (b) a table (c) a pop-up box (d) a picture
-
8.⚡ What number does this code print?
let apples = 25;
apples = apples + 9;
apples = apples - 25;
console.log(apples); - 9.⚡ Which JavaScript word shows a pop-up box? (a) console.log() (b) alert() (c) for (d) let
-
10.⚡ What does this code print? (Look at the quotes!)
let x = "7";
let y = 1;
console.log(x + y); (a) Error (b) 71 (c) 8 - 11.⚡ Which JavaScript word makes a new variable? (a) for (b) let (c) if (d) alert()
-
12.⚡ What does this code print? (Look at the quotes!)
let x = "3";
let y = 1;
console.log(x + y); (a) 4 (b) Error (c) 31 - 13.⚡ Which JavaScript word writes in the console? (a) let (b) alert() (c) if (d) console.log()
-
14.⚡ What number does this code print?
let apples = 9;
apples = apples + 2;
apples = apples - 10;
console.log(apples); -
15.⚡ What number does this code print?
let apples = 22;
apples = apples + 4;
apples = apples - 4;
console.log(apples); -
16.⚡ What does this code show?
let name = "Meera";
alert("Hi, " + name + "!"); (a) Hi, Meera! (b) name (c) Meera (d) Hi, name! -
17.⚡ What does this code show?
let name = "Aman";
alert("Hello, " + name + "!"); (a) Aman (b) Hello, name! (c) name (d) Hello, Aman! -
18.⚡ What number does this code print?
let coins = 29;
coins = coins + 9;
coins = coins - 37;
console.log(coins); -
19.⚡ What number does this code print?
let runs = 5;
runs = runs + 16;
runs = runs - 18;
console.log(runs); -
20.⚡ What does this code show?
let name = "Arjun";
console.log("Welcome, " + name + "!"); (a) Welcome, name! (b) name (c) Welcome, Arjun! (d) Arjun -
21.⚡ What does this code print? (Look at the quotes!)
let x = "6";
let y = 4;
console.log(x + y); (a) Error (b) 64 (c) 10 -
22.⚡ What number does this code print?
let apples = 23;
apples = apples + 19;
apples = apples - 34;
console.log(apples); -
23.⚡ What number does this code print?
let a = 2;
let b = 10;
console.log(a * b); -
24.⚡ What number does this code print?
let books = 21;
books = books + 20;
books = books - 4;
console.log(books); -
25.⚡ What number does this code print?
let a = 42;
let b = 30;
console.log(a - b); - 26.⚡ Where does console.log() show its output? (a) in the console (b) in the address bar (c) on the title bar (d) on the printer
-
27.⚡ What does this code show?
let name = "Riya";
alert("Well done, " + name + "!"); (a) Well done, name! (b) Riya (c) name (d) Well done, Riya! -
28.⚡ What does this code print? (Look at the quotes!)
let x = "6";
let y = 3;
console.log(x + y); (a) 63 (b) Error (c) 9 - 29.⚡ Which JavaScript word repeats code? (a) for (b) alert() (c) let (d) if
- 30.⚡ What does JavaScript add to a web page? (a) actions and changes (b) the page title (c) the domain name (d) only colours
-
31.⚡ What number does this code print?
let a = 52;
let b = 13;
console.log(a + b); -
32.⚡ What does this code print? (Look at the quotes!)
let x = "9";
let y = 3;
console.log(x + y); (a) Error (b) 12 (c) 93 -
33.⚡ What does this code show?
let name = "Kabir";
console.log("Hello, " + name + "!"); (a) name (b) Hello, name! (c) Kabir (d) Hello, Kabir! -
34.⚡ What does this code print? (Look at the quotes!)
let x = "3";
let y = 8;
console.log(x + y); (a) 11 (b) Error (c) 38 -
35.⚡ What does this code print? (Look at the quotes!)
let x = "4";
let y = 5;
console.log(x + y); (a) 45 (b) 9 (c) Error - 36.⚡ Which tag holds JavaScript in a page? (a) <js> (b) <style> (c) <code> (d) <script>
-
37.⚡ What number does this code print?
let score = 10;
score = score + 4;
score = score - 7;
console.log(score); - 38.⚡ Which word makes a new variable? (a) give (b) make (c) put (d) let
-
39.⚡ What does this code print? (Look at the quotes!)
let x = "8";
let y = 4;
console.log(x + y); (a) 12 (b) 84 (c) Error -
40.⚡ What does this code print? (Look at the quotes!)
let x = "5";
let y = 4;
console.log(x + y); (a) Error (b) 54 (c) 9
Answer key
- 3
- 32
- 13
- if
- 74
- 21
- a pop-up box
- 9
- alert()
- 71
- let
- 31
- console.log()
- 1
- 22
- Hi, Meera!
- Hello, Aman!
- 1
- 3
- Welcome, Arjun!
- 64
- 8
- 20
- 37
- 12
- in the console
- Well done, Riya!
- 63
- for
- actions and changes
- 65
- 93
- Hello, Kabir!
- 38
- 45
- <script>
- 7
- let
- 84
- 54
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids