← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. actions and changes
  2. 22
  3. 6
  4. 44
  5. if
  6. 24
  7. 97
  8. 48
  9. Well done, Arjun!
  10. 39
  11. console.log()
  12. a pop-up box
  13. 19
  14. 1
  15. 13
  16. 19
  17. let
  18. 27
  19. in the console
  20. Welcome, Aman!
  21. 8
  22. 28
  23. 11
  24. Welcome, Riya!
  25. 20
  26. .js
  27. alert()
  28. 6
  29. 54
  30. 1
  31. 83
  32. 20
  33. for
  34. Hello, Zoya!
  35. 86
  36. 76
  37. 38
  38. 39
  39. 69
  40. 31

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