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