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