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