← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. let
  2. actions and changes
  3. in the console
  4. 89
  5. if
  6. 49
  7. console.log()
  8. a pop-up box
  9. .js
  10. 95
  11. Welcome, Arjun!
  12. Hi, Kabir!
  13. 19
  14. Welcome, Kabir!
  15. alert()
  16. Welcome, Aman!
  17. Hello, Zoya!
  18. for
  19. 25
  20. Welcome, Zoya!
  21. 47
  22. 13
  23. 1
  24. 21
  25. 8
  26. Hi, Arjun!
  27. 11
  28. 0
  29. 27
  30. Hi, Meera!
  31. let
  32. 110
  33. 4
  34. 15
  35. 92
  36. 60
  37. 76
  38. 15
  39. <script>
  40. 41

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