← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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