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