← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. actions and changes
  2. 11
  3. <script>
  4. let
  5. 34
  6. 12
  7. 69
  8. 17
  9. 21
  10. 24
  11. 24
  12. Hi, Arjun!
  13. 65
  14. 85
  15. 15
  16. Welcome, Arjun!
  17. 52
  18. a pop-up box
  19. 90
  20. Hello, Arjun!
  21. Well done, Riya!
  22. 89
  23. 5
  24. .js
  25. 69
  26. let
  27. for
  28. 1
  29. 25
  30. 13
  31. Hi, Zoya!
  32. 33
  33. 49
  34. 96
  35. 31
  36. console.log()
  37. 22
  38. Hi, Aman!
  39. 59
  40. 96

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