← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. Well done, Riya!
  2. alert()
  3. 98
  4. 8
  5. for
  6. 19
  7. if
  8. actions and changes
  9. 2
  10. 94
  11. let
  12. 4
  13. console.log()
  14. in the console
  15. <script>
  16. 51
  17. Well done, Meera!
  18. 32
  19. 3
  20. .js
  21. a pop-up box
  22. 110
  23. let
  24. 28
  25. 49
  26. 19
  27. 12
  28. 45
  29. Hi, Riya!
  30. 38
  31. 99
  32. 19
  33. 49
  34. 60
  35. 10
  36. Hello, Aman!
  37. Hello, Riya!
  38. Hello, Aman!
  39. 65
  40. 4

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