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