← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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