← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. if
  2. <script>
  3. 11
  4. console.log()
  5. .js
  6. Welcome, Kabir!
  7. alert()
  8. for
  9. 13
  10. in the console
  11. 89
  12. 6
  13. 30
  14. let
  15. 42
  16. let
  17. 41
  18. 65
  19. actions and changes
  20. 33
  21. 24
  22. 25
  23. 33
  24. 19
  25. 16
  26. Hello, Zoya!
  27. 4
  28. 7
  29. 23
  30. 85
  31. 64
  32. 8
  33. 40
  34. 46
  35. a pop-up box
  36. 47
  37. 39
  38. 57
  39. Hello, Arjun!
  40. 43

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