← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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