← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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