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