← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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