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