← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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