← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. 36
  2. Well done, Arjun!
  3. 59
  4. 48
  5. 25
  6. for
  7. Hi, Aman!
  8. alert()
  9. actions and changes
  10. .js
  11. let
  12. 13
  13. 55
  14. let
  15. 88
  16. 44
  17. 12
  18. 33
  19. Welcome, Meera!
  20. 61
  21. if
  22. Hello, Meera!
  23. 89
  24. 63
  25. Welcome, Riya!
  26. 49
  27. 39
  28. 23
  29. 8
  30. 24
  31. 92
  32. <script>
  33. 34
  34. Well done, Meera!
  35. console.log()
  36. 36
  37. a pop-up box
  38. 14
  39. 10
  40. 1

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