← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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