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