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