← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. let
  2. a pop-up box
  3. <script>
  4. 20
  5. Hello, Riya!
  6. 14
  7. console.log()
  8. let
  9. 2
  10. 4
  11. .js
  12. if
  13. 87
  14. 78
  15. 17
  16. alert()
  17. 27
  18. Hi, Aman!
  19. for
  20. 85
  21. Welcome, Kabir!
  22. 18
  23. 23
  24. 35
  25. Hi, Zoya!
  26. 88
  27. actions and changes
  28. 86
  29. 12
  30. 46
  31. 22
  32. 2
  33. 17
  34. Welcome, Arjun!
  35. 9
  36. 54
  37. 48
  38. 28
  39. 14
  40. Hello, Zoya!

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