← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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