← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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