← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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