← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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