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