← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. console.log()
  2. if
  3. 0
  4. let
  5. 32
  6. in the console
  7. .js
  8. 41
  9. 27
  10. 32
  11. 85
  12. Welcome, Arjun!
  13. let
  14. Hi, Zoya!
  15. 70
  16. a pop-up box
  17. 94
  18. for
  19. 72
  20. 28
  21. alert()
  22. Well done, Riya!
  23. 25
  24. Well done, Meera!
  25. actions and changes
  26. 54
  27. Hello, Zoya!
  28. Well done, Meera!
  29. 35
  30. <script>
  31. 48
  32. 8
  33. 62
  34. 28
  35. Welcome, Aman!
  36. 1
  37. 66
  38. Hello, Kabir!
  39. 20
  40. 11

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