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
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.
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.
if you pay attention to this part:
Below that lowercaseWord variable, create another variable called camelCasedVersion and assign it an empty string for now.
!!spoilers!!
it means you should add an empty string (“”) to the camelCasedVersion variabel.
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.