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