← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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