← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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