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