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