← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. a pop-up box
  2. let
  3. 17
  4. <script>
  5. 90
  6. 8
  7. 1
  8. 93
  9. 75
  10. 95
  11. alert()
  12. in the console
  13. 6
  14. if
  15. for
  16. 36
  17. 34
  18. 67
  19. 7
  20. 11
  21. Hi, Zoya!
  22. 62
  23. 73
  24. console.log()
  25. 52
  26. 78
  27. actions and changes
  28. 19
  29. let
  30. .js
  31. 60
  32. Welcome, Riya!
  33. 8
  34. 40
  35. 56
  36. 1
  37. 9
  38. Well done, Aman!
  39. 11
  40. Welcome, Riya!

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