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