← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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