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