String Methods, online

Six activities your students do on their own devices. See who's finished, and their scores.

String Methods in one minute

What students need to know

toLowerCase() returns a new string with all lowercase letters. trim() cleans up whitespace at the start and end of a string.

toUpperCase() converts every letter to uppercase in a new string. JavaScript uses camelCase, so it must be toUpperCase.

Mistakes students make

  • 'trim' must be lowercase - a capital T causes an error.
  • Method names are camelCase - it should be toUpperCase, not touppercase.
  • Missing parentheses - toUpperCase() needs to be called.
  • Missing parentheses - trim() needs to be called.

Discover other journeys with this module

What students will learn in this module

Every question in Module 30

Quick questions

  1. Does toUpperCase() return a new string in all caps?AYesBNo
  2. Does toLowerCase() change the original string?ANoBYes
  3. Does trim() remove whitespace from the start and end?AYesBNo
  4. Is 'touppercase' with no capitals valid JavaScript syntax?AYesBNo
  5. Do these string methods need parentheses to be called?ANoBYes

Key terms

Students type the meaning of:

  • toUpperCase()

Match the pairs

name.toUpperCase()Match it to what it does
name.trim()Match it to what it does
Converts every letter of a string to lowercaseMatch it to what it does
Removes leading and trailing whitespace from a stringMatch it to what it does
text.touppercase()Match it to what it does
text.Trim()Match it to what it does

Fill in the blanks

  1. console.log(name.___________());

    Hint: Type the method that converts a string to all uppercase.

  2. console.log(name.___________());

    Hint: Type the method that converts a string to all lowercase.

  3. console.log(name.____());

    Hint: Type the method that removes whitespace from both ends.

  4. let upper = word.___________();

    Hint: Type the method that converts a string to all uppercase.

  5. let trimmed = input.____();

    Hint: Type the method that removes whitespace from both ends.

Spot the error

Question 1

Alet a = " hi ";Bconsole.log(a.Trim());Cconsole.log(a);

Question 2

Alet b = "Hi";Bconsole.log(b.touppercase());Cconsole.log(b);

Question 3

Alet f = "Hi";Bconsole.log(f);Cconsole.log(f.toUpperCase);

Question 4

Aconsole.log(g.trim);Blet g = " hi ";Cconsole.log(g);

Question 5

Alet h = "Hi";Bconsole.log(h.toUpperCase());Cconsole.log(h);Dconsole.log(h.touppercase());