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