← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. Welcome, Meera!
  2. 2
  3. console.log()
  4. Hi, Arjun!
  5. 89
  6. Welcome, Zoya!
  7. <script>
  8. in the console
  9. Hello, Meera!
  10. Hi, Zoya!
  11. Hi, Zoya!
  12. for
  13. 15
  14. 23
  15. a pop-up box
  16. 73
  17. alert()
  18. 7
  19. let
  20. 49
  21. 5
  22. actions and changes
  23. let
  24. 24
  25. Well done, Meera!
  26. .js
  27. 99
  28. 56
  29. 23
  30. 3
  31. 66
  32. 15
  33. 33
  34. 29
  35. Hi, Meera!
  36. 24
  37. Hello, Kabir!
  38. 16
  39. 40
  40. 6

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