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