← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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