← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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