← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. Well done, Meera!
  2. alert()
  3. for
  4. Welcome, Kabir!
  5. let
  6. Welcome, Kabir!
  7. 18
  8. let
  9. <script>
  10. 91
  11. 52
  12. in the console
  13. 25
  14. 16
  15. console.log()
  16. 22
  17. Welcome, Riya!
  18. 15
  19. .js
  20. 1
  21. 7
  22. 144
  23. 9
  24. 63
  25. 94
  26. if
  27. 11
  28. 1
  29. 13
  30. 66
  31. 55
  32. 36
  33. actions and changes
  34. Hi, Meera!
  35. 27
  36. a pop-up box
  37. 54
  38. 71
  39. 12
  40. 60

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