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