Build a String Formatter - Step 15

Tell us what’s happening:

ive copied and pasted, reset, and tried a million formats. What am i doing wrong???

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.

Your code so far

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";

// User Editable Region

const camelCasedVersion = lowercaseWord.slice(0, 5)
console.log(lowercaseWord.slice(0, 5) + lowercaseWord[5].toUpperCase())

// User Editable Region

console.log("Camel cased version:");
console.log(camelCasedVersion);

Your browser information:

User Agent is: Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36

Challenge Information:

Build a String Formatter - Step 15

2 Likes

The console log is good, but I think you need to assign it to the variable `camelCasedVersion`. Perhaps the tests are expecting a log from this specific variable?

tried that! didn’t work, maybe I put it in wrong> I did it like this:

const camelCasedVersion = lowercaseWord.slice(0, 5)

console.log(camelCasedVersion + lowercaseWord[5].toUpperCase())

Hi,

As you can see, you are already logging the camelCasedVersion variable to the console, so all you have to do is concatenate things to that variable only.

Good luck!

1 Like

at the moment the variable only reads as “camel” though… It’s not enough to log the right result. It has to be stored to the variable.

1 Like

code removed by moderator

This is the required result there

hi @sandipis222

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge. How to Help Someone with Their Code Using the Socratic Method

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

wait what? this is what I have.

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

console.log(camelCasedVersion + lowercaseWord[5].toUpperCase())

the instructions seem to say to use the first one, but the comments say the second one might work. neither do though…

You should concatenate lowercaseWord.slice(0, 5) with lowercaseWord[5].toUpperCase().

this is the error its giving

I got it! I had to add to the variable instead of log lol!

2 Likes