← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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