← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. 12
  2. let
  3. 37
  4. 59
  5. 99
  6. Hello, Arjun!
  7. <script>
  8. for
  9. in the console
  10. Hi, Kabir!
  11. actions and changes
  12. 22
  13. let
  14. 25
  15. 95
  16. 34
  17. 81
  18. 52
  19. 32
  20. 4
  21. 11
  22. 17
  23. console.log()
  24. 50
  25. .js
  26. 21
  27. if
  28. 2
  29. 51
  30. 14
  31. 33
  32. alert()
  33. 17
  34. 84
  35. 9
  36. Hi, Aman!
  37. Welcome, Meera!
  38. 2
  39. 26
  40. 54

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