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