← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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