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