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