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