← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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