ApexSensei

Drills Apex basics

Clean a Contact name

Apex String methods such as trim and capitalize turn messy imported text into clean names.

Your task

Clean two imported Contact names: trim the spaces, fix the capital letters, and drop the __temp suffix.

String firstName = '  maya  ';
String lastName = 'Chen__temp';

// Case A: maya / Chen

// Case B: LUCIA / Lopez
firstName = '  LUCIA  ';
lastName = 'Lopez__temp';

Requirements

  1. trim() should be used
  2. capitalize() should be used
  3. removeEnd, remove or replace should be used on '__temp'
  4. First: Maya should be printed
  5. Last: Chen should be printed
  6. Full: Maya Chen should be printed
  7. Second full: Lucia Lopez should be printed

Sign in to open this drill