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