← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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