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