← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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