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