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