← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. 92
  2. console.log()
  3. .js
  4. in the console
  5. 45
  6. 32
  7. if
  8. actions and changes
  9. 37
  10. 18
  11. 11
  12. 2
  13. Well done, Zoya!
  14. 44
  15. a pop-up box
  16. let
  17. for
  18. 42
  19. Hello, Kabir!
  20. Hi, Riya!
  21. 0
  22. alert()
  23. 4
  24. let
  25. 9
  26. 67
  27. 14
  28. 13
  29. Hi, Zoya!
  30. 41
  31. 7
  32. 7
  33. 35
  34. 85
  35. 31
  36. Hi, Riya!
  37. 20
  38. <script>
  39. 37
  40. 8

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