← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. 99
  2. 13
  3. Well done, Aman!
  4. actions and changes
  5. .js
  6. 3
  7. let
  8. if
  9. <script>
  10. 65
  11. 21
  12. alert()
  13. 74
  14. a pop-up box
  15. 52
  16. 11
  17. 52
  18. 6
  19. let
  20. 9
  21. for
  22. 72
  23. console.log()
  24. Welcome, Aman!
  25. Welcome, Riya!
  26. 87
  27. 4
  28. 99
  29. 86
  30. 16
  31. 91
  32. 17
  33. 14
  34. 132
  35. 64
  36. 7
  37. Welcome, Kabir!
  38. 60
  39. 46
  40. 52

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