← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

HTML and CSS lesson 25: JavaScript basics · Set 889 · 40 questions
TalentJR

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

Answer key

  1. 29
  2. .js
  3. 1
  4. console.log()
  5. let
  6. actions and changes
  7. let
  8. 16
  9. 2
  10. if
  11. 6
  12. 5
  13. Hello, Zoya!
  14. 91
  15. 39
  16. 43
  17. Well done, Arjun!
  18. Hi, Arjun!
  19. for
  20. 25
  21. <script>
  22. 12
  23. Hello, Meera!
  24. 37
  25. a pop-up box
  26. 12
  27. 93
  28. Well done, Zoya!
  29. Hello, Aman!
  30. 70
  31. 5
  32. 16
  33. 17
  34. Well done, Kabir!
  35. 35
  36. Welcome, Riya!
  37. 43
  38. in the console
  39. 2
  40. 8

Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids