← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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