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