← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. .js
  2. for
  3. let
  4. alert()
  5. console.log()
  6. 11
  7. 32
  8. Well done, Riya!
  9. 13
  10. 49
  11. 52
  12. actions and changes
  13. let
  14. Well done, Zoya!
  15. Hi, Riya!
  16. 63
  17. Welcome, Zoya!
  18. 33
  19. 1
  20. 62
  21. 18
  22. 9
  23. 28
  24. 21
  25. 9
  26. <script>
  27. 74
  28. 3
  29. 26
  30. 67
  31. if
  32. 0
  33. Hello, Meera!
  34. in the console
  35. 21
  36. 81
  37. 16
  38. Hello, Meera!
  39. Well done, Riya!
  40. 37

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