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