← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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