← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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