JAVASCRIPT / STRINGS · STEP 1 OF 5
Clean and inspect a text label
Checking your account…
GUIDED PRACTICE
Clean and inspect a text label
Follow the current step, write the requested code and choose Run & check this step. Your own program carries forward.
Your code stays in one editor through every step. Word wrap is enabled.
Step 1 of 5
Keep the original text
User-supplied text can include surrounding spaces. Preserve the original so you can compare it with a cleaned copy.
Your task
In script.js, make the changes in the checklist. Keep the working code from earlier steps.
To pass this step:
- Declare
const rawLabel = " Code Club ";with two spaces on each side.
Press the play button labeled Run & check this step below the editor to run your code and see your check results.
Your editor is opening.
Each step builds on the last. Finish the current step before opening the next one; your code stays with you.
This is one possible solution. Compare it with your own code; opening it does not replace your work or complete a step.
// Build your program one step at a time.
const rawLabel = " Code Club ";// Build your program one step at a time.
const rawLabel = " Code Club ";
const cleanLabel = rawLabel.trim();// Build your program one step at a time.
const rawLabel = " Code Club ";
const cleanLabel = rawLabel.trim();
const searchLabel = cleanLabel.toLowerCase();
console.log(searchLabel);// Build your program one step at a time.
const rawLabel = " Code Club ";
const cleanLabel = rawLabel.trim();
const searchLabel = cleanLabel.toLowerCase();
console.log(searchLabel);
console.log(cleanLabel.slice(0, 4));// Build your program one step at a time.
const rawLabel = " Code Club ";
const cleanLabel = rawLabel.trim();
const searchLabel = cleanLabel.toLowerCase();
console.log(searchLabel);
console.log(cleanLabel.slice(0, 4));
console.log(rawLabel.length);
console.log(cleanLabel.length);Code and completed steps save in this browser when signed out. Sign in to save across devices.
Choose the copy to continue. Your account work will only be replaced if you choose this device.
Ready to checkRun the checks to see your results here.