← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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