← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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