← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. Hello, Kabir!
  2. alert()
  3. let
  4. 41
  5. 55
  6. Hi, Zoya!
  7. in the console
  8. 32
  9. <script>
  10. console.log()
  11. 24
  12. .js
  13. Hello, Meera!
  14. for
  15. 18
  16. 52
  17. Hello, Riya!
  18. 32
  19. 5
  20. actions and changes
  21. 16
  22. Hi, Aman!
  23. 14
  24. 69
  25. 34
  26. 72
  27. Hi, Arjun!
  28. let
  29. if
  30. 67
  31. 92
  32. Welcome, Aman!
  33. a pop-up box
  34. 59
  35. 44
  36. 28
  37. 77
  38. 90
  39. 26
  40. 7

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