← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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