← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. 58
  2. console.log()
  3. if
  4. .js
  5. 9
  6. 68
  7. 39
  8. 27
  9. let
  10. 32
  11. Hi, Riya!
  12. Hello, Meera!
  13. 16
  14. 16
  15. actions and changes
  16. 13
  17. 6
  18. 5
  19. 30
  20. for
  21. Hello, Meera!
  22. 30
  23. 43
  24. 24
  25. alert()
  26. 45
  27. 26
  28. 55
  29. 42
  30. a pop-up box
  31. 58
  32. 44
  33. let
  34. 14
  35. 78
  36. 16
  37. Hi, Riya!
  38. 24
  39. 49
  40. Hello, Kabir!

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