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