Javascript: .trim() usage

Hello friends,

I have a simple question, why this one works?

const palindromeChecker = (word) => {
	const testedWord = word.split("").reverse().join("");

	testedWord === word
		? console.log(`Tested word ${word} is a palindrome: ${testedWord}`)
		: console.log(` Tested word ${word} is not palindrome: ${testedWord}`);
};

palindromeChecker("mirim             ".trim());

And this doens’t ?

const palindromeChecker = (word) => {
	const testedWord = word.trim().split("").reverse().join("");

	testedWord === word
		? console.log(`Tested word ${word} is a palindrome: ${testedWord}`)
		: console.log(` Tested word ${word} is not palindrome: ${testedWord}`);
};

palindromeChecker("mirim             ");

Hello Lucas,

Thanks for the reply, I know what trim() does.

My question is why this work in my first function but not in my second.

because you are checking the original argument against the argument stripped of unwanted characters and reversed
for word you are missing the “stripped of unwanted characters” part

Ow now I see my mistake, thanks.