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