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