← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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