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