← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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