Build a String Formatter - Step 13

Tell us what’s happening:

Getting the error - "You should have a variable called “lowecaseWord”

I don’t know what I’m doing wrong at the moment. Might be wrong, but I think I’ve added the variable correctly.
I’m going through it already for some time and can’t see the mistake exactly.
Can anyone give me a hint about what’s happening?

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


// User Editable Region

const lowercaseWord = "camelcase";
const camelCasedVersion;
console.log("Camel cased version:");
console.log(camelCasedVersion);

// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36

Challenge Information:

Build a String Formatter - Step 13

Welcome to the forum @joaom534!

I think it´s a better idea to associate value to new variables.

Yep! Got the hint. Have been on going with const and thought it would be the case. Didn’t think that this could sort it out. Guess I was wrong :sweat_smile:

Thanks a lot for the hint!

Actually no, this didn’t work quite well. I managed to get past through it, but it still doesn’t clarify on why it worked.

I changed to let instead of const and then also edited the part missing for “const camelCasedVersion; “
I really don’t know if that was the reason or not, but added = ““ ; after this and it fixed?

Also swapping const to let seemed to have fixed the issue, perhaps, but I didn’t understand it’s relevance now since it came back to const in the next step. :thinking:

Then, at the same time, the error message was related directly to the variable lowercaseWord , which makes things a bit confusing for me. Is there something I’m not getting?

Well, const makes the variable not editable, so if you doesn´t associate a value when you declare it, you will not able to do it later. It will be forever undefined and as you have seen, the console thows an error too.

A pointless variable with undefined value makes no sense to have, while variables declared with let can be edited later.
Still not a good practice to not giving a value, when you declare a new variable.

Like you can use var too if you want, but why should you?
You will learn about it later, but here is the link to start with if you are intertested.