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