Questions about trim command in JavaScript

Working through day 1 of JavaScript. No previous experience. 1st post so hopefully I can figure out how to best post the problem I have in the correct location.

The tutorial shows:

2.

In the second console.log() statement in app.js , we have a string ' Remove whitespace ' which has spaces before and after the words 'Remove whitespace' .

If we browse the JavaScript string documentation, we find several built-in string methods that each accomplish a different goal. The one method that seems ideal for us is .trim() .

Use the method to remove the whitespace at the beginning and end of the string in the second console.log() statement.

I don’t see ' Remove whitespace ' in the tutorial code. Here’s a snapshot of what is showing on my screen:

Can someone shed some light?

Thanks

Hi,

Can you link to the lesson? Did they introduce other methods? Maybe replace()?

https://www.codecademy.com/courses/introduction-to-javascript/lessons/introduction-to-javascript/exercises/built-in-methods

The tutorial states:

In the second console.log() statement in app.js , we have a string ' Remove whitespace ' which has spaces before and after the words 'Remove whitespace' .

The words Remove whitespace do not exist. The tutorial says they do but they don’t appear on my screen. Maybe this is a bug or typo?

Appreciate your assistance.

Yea the exercise is being quite literal here. It doesn’t want you to store the string. It wants you to apply the method directly to the string.

Since the string “Remove whitespace” does not exist, how can I apply the Term method to a string that does not exist?? Sorry for all the questions.

Here’s an idea:

console.log("i think bread is neat".toUpperCase());

Ok, so I can just make up a string since they one they reference does not exist? Do you think doing this will allow me to continue progress in my lesson or is the answer the website provides the “only” right answer?

If it’s the only right answer you will be able to click “see solution” or something.
It’s not a terrible idea to do that if you’re stuck for too long.
(In this case the difference would be trivial at best, but sometimes certain situations call for very precise following of algorithms).

Alrighty, will give this a shot.

THANKS so much for stepping up. We’ll see how it goes.

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