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