← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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