← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. 37
  2. 39
  3. console.log()
  4. let
  5. 18
  6. in the console
  7. 21
  8. 58
  9. for
  10. 9
  11. let
  12. alert()
  13. 66
  14. 34
  15. 26
  16. 15
  17. 63
  18. .js
  19. actions and changes
  20. 15
  21. 0
  22. if
  23. 8
  24. 66
  25. 91
  26. 48
  27. 21
  28. Welcome, Arjun!
  29. 39
  30. 32
  31. 24
  32. 31
  33. 12
  34. 2
  35. 22
  36. 40
  37. 14
  38. Hi, Aman!
  39. 49
  40. 51

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