← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. 6
  2. alert()
  3. <script>
  4. for
  5. 75
  6. 32
  7. Welcome, Arjun!
  8. 31
  9. Hello, Zoya!
  10. 11
  11. 24
  12. .js
  13. 65
  14. Welcome, Kabir!
  15. let
  16. 64
  17. 1
  18. Hi, Kabir!
  19. 18
  20. console.log()
  21. 10
  22. 68
  23. 23
  24. 6
  25. 16
  26. 98
  27. 4
  28. actions and changes
  29. in the console
  30. 50
  31. Welcome, Kabir!
  32. 18
  33. 24
  34. let
  35. 51
  36. 17
  37. 42
  38. Hello, Kabir!
  39. 61
  40. 83

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