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