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