← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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