JavaScript Build a string formatter step 15

const userInput = " Hello World! ";

console.log(“Original input:”);

console.log(userInput);

const cleanedInput = userInput.trim();

console.log(“Result of trimming whitespace from both ends:”);

console.log(cleanedInput);

const trimmedStart = userInput.trimStart();

console.log(“After using the trimStart() method, leading spaces removed:”);

console.log(trimmedStart);

const trimmedEnd = userInput.trimEnd();

console.log(“After using the trimEnd() method, trailing spaces removed:”);

console.log(trimmedEnd);

const upperCaseInput = cleanedInput.toUpperCase();

console.log(“Result of using the toUpperCase() method:”);

console.log(upperCaseInput);

const lowerCaseInput = cleanedInput.toLowerCase();

console.log(“Result of using the toLowerCase() method:”);

console.log(lowerCaseInput);

const lowercaseWord = “camelcase”;

const camelCasedVersion = lowercaseWord.slice(0, 5)

console.log(“Camel cased version:”);

console.log(camelCasedVersion);

console.log(`lowercaseWord.slice(0, 5) + lowercaseWord[5].toUpperCase()`);

The instructions are:

Step 15

As you recall from earlier lessons, the camelCase naming convention starts with a lowercase letter for the first word, and each subsequent word begins with an uppercase letter followed by lowercase letters.

Here are some reminder examples:

Example Code
freeCodeCamp
camelCase
learningIsFun

The second word in the lowercaseWord variable is "case". To access the c in that word, you can use lowercaseWord[5].

Use the + operator to concatenate lowercaseWord.slice(0, 5) with the result of using the correct method for converting strings to uppercase on lowercaseWord[5].

Now you should see camelC in the console.

please share a link to the step, and also please format your code

When you enter a code block into a forum post, please precede it with three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add the backticks.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

Ok, my bad. I will fix it

once you do that we will be ready to help you :slight_smile:

My code:

const userInput = " Hello World! ";

console.log(“Original input:”);

console.log(userInput);

const cleanedInput = userInput.trim();

console.log(“Result of trimming whitespace from both ends:”);

console.log(cleanedInput);

const trimmedStart = userInput.trimStart();

console.log(“After using the trimStart() method, leading spaces removed:”);

console.log(trimmedStart);

const trimmedEnd = userInput.trimEnd();

console.log(“After using the trimEnd() method, trailing spaces removed:”);

console.log(trimmedEnd);

const upperCaseInput = cleanedInput.toUpperCase();

console.log(“Result of using the toUpperCase() method:”);

console.log(upperCaseInput);

const lowerCaseInput = cleanedInput.toLowerCase();

console.log(“Result of using the toLowerCase() method:”);

console.log(lowerCaseInput);

const lowercaseWord = “camelcase”;

const camelCasedVersion = lowercaseWord.slice(0, 5)

console.log(“Camel cased version:”);

console.log(camelCasedVersion);

console.log(`lowercaseWord.slice(0, 5) + lowercaseWord[5].toUpperCase()`);

You are asked to concatenate to this assignment, not log the concatenation result.

You may want to reset this step and try again.

1 Like

If you have a question about a specific challenge as it relates to your written code for that challenge and need some help, click the Help button located on the challenge.

The Help button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Thank you.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.