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