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