← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. 92
  2. console.log()
  3. 25
  4. <script>
  5. 46
  6. 21
  7. 66
  8. a pop-up box
  9. alert()
  10. 110
  11. let
  12. 27
  13. 36
  14. 7
  15. Well done, Arjun!
  16. Well done, Meera!
  17. 58
  18. 86
  19. Well done, Zoya!
  20. Welcome, Kabir!
  21. 34
  22. for
  23. 16
  24. 83
  25. 55
  26. .js
  27. if
  28. in the console
  29. Welcome, Aman!
  30. Hi, Kabir!
  31. 7
  32. 62
  33. 1
  34. 40
  35. Well done, Zoya!
  36. 62
  37. 20
  38. 1
  39. 24
  40. 22

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