← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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