← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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