Hard to understand instruction

I am on this project and I can’t understand what they are telling me to have the function do on instruction 9, where it says:

Continue by adding a few additional functions to the MessageMixer module.

In messageMixer.js, create a function on the MessageMixer object called palindrome() that takes a String str as a parameter.

The body of the function should use string concatenation or interpolation to return the string, a space, and the reverse of the string. You can use the reverseWord() function. You will need to call reverseWord() as a method of MessageMixer.

Specifically the part where it says “… the reverse of the string. …”. Does that mean reverse each word in the string, put the words in opposite order, or what?

My palindrome function for this project returns the following output:

What is the color of the sky? ?yks eht fo roloc eht si tahW

The above reply notwithstanding, we should be clear on what a palindrome is.


is the same thing when it is reversed. The same would apply to any string (phrase or word). If we are trying to determine if an input is palindromic then we compare it to its reverse.

According to the last paragraph of the instructions… Add this method to your object:

palindrome (str) {
    return `${str} ${reverseWord(str)}`  // using interpolation

Be sure that your reverseWord() function is global, and that it works as expected so the above returns something similar to what @midlindner showed for his result.

That means the function is not global, after all. It and palindrome are both methods as I interpret the instruction. How you going to put this together?

1 Like

The point of the exercise is that reverseWord is not global. @eunoias, not sure how much this matters now, but you should be using this.reverseWord to call the function, even when you’re calling it in the other functions where you’re defining MessageMixer.someFunction=function()...