← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. Hi, Kabir!
  2. let
  3. 62
  4. if
  5. a pop-up box
  6. 8
  7. 88
  8. 98
  9. alert()
  10. 33
  11. 23
  12. 46
  13. 69
  14. console.log()
  15. Hi, Arjun!
  16. actions and changes
  17. Welcome, Zoya!
  18. for
  19. 60
  20. 27
  21. 10
  22. Well done, Kabir!
  23. <script>
  24. 23
  25. 0
  26. 39
  27. 7
  28. Welcome, Arjun!
  29. Hi, Meera!
  30. let
  31. 49
  32. .js
  33. 14
  34. Hi, Aman!
  35. 68
  36. 44
  37. 30
  38. 20
  39. 87
  40. 31

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