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