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