← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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