← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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