← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. Welcome, Aman!
  2. actions and changes
  3. Hi, Zoya!
  4. 23
  5. 144
  6. let
  7. for
  8. Hi, Meera!
  9. let
  10. Welcome, Riya!
  11. a pop-up box
  12. 64
  13. <script>
  14. 41
  15. Welcome, Meera!
  16. 42
  17. 54
  18. 97
  19. 0
  20. if
  21. 94
  22. Welcome, Zoya!
  23. console.log()
  24. 51
  25. .js
  26. alert()
  27. in the console
  28. 1
  29. 10
  30. Welcome, Kabir!
  31. 53
  32. 14
  33. 62
  34. 31
  35. 37
  36. 2
  37. 21
  38. 69
  39. 17
  40. 34

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