← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. let
  2. 34
  3. Well done, Arjun!
  4. a pop-up box
  5. Welcome, Zoya!
  6. 5
  7. 42
  8. Hello, Zoya!
  9. Well done, Riya!
  10. 5
  11. 54
  12. let
  13. 43
  14. 74
  15. console.log()
  16. Hello, Meera!
  17. in the console
  18. 23
  19. Hi, Riya!
  20. 60
  21. 32
  22. 66
  23. Hi, Arjun!
  24. alert()
  25. Well done, Zoya!
  26. 41
  27. 83
  28. 28
  29. actions and changes
  30. .js
  31. for
  32. if
  33. 13
  34. 61
  35. 7
  36. 10
  37. 5
  38. 7
  39. 17
  40. 8

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