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