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