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