← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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