← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. 51
  2. 5
  3. for
  4. 10
  5. 35
  6. Hello, Arjun!
  7. a pop-up box
  8. 12
  9. .js
  10. 33
  11. 21
  12. 21
  13. Well done, Aman!
  14. 59
  15. 79
  16. let
  17. 23
  18. 53
  19. Well done, Arjun!
  20. if
  21. <script>
  22. 24
  23. 17
  24. alert()
  25. 15
  26. 1
  27. Hello, Kabir!
  28. console.log()
  29. 50
  30. 66
  31. 13
  32. 27
  33. 58
  34. 69
  35. 86
  36. let
  37. 6
  38. 77
  39. 15
  40. 38

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