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