Am I doing this correctly so far? I am afraid to continue because I am not sure if things are going the way needed to pass. I see that it says it needs the name of the message but I seem to have difficulty grasping the idea. Are they asking for message.name to be in the result? So far, test 9 is passing and the variables match. If message.name is needed, then I would need to recode that portion.
Is there any information to help me understand what I am doing exactly? The “book” teaches me how the idea of objects work with the classes but it doesn’t teach me how to apply the objects. To me, it’s difficult applying something that I haven’t exactly learned and I get frustrated trying to understand the logic. I have been stuck on test 9 for almost a week and it’s simply because I don’t understand how to apply the objects correctly. Are there any websites that could help me understand?
You’re definitely on the right track, so no need to fear.
Yes, test 8 is asking you to test whether the object rover.receiveMessage() returns contains the name of the message passed as an argument. This name is one of the properties of the message object receiveMessage() expects as an argument, found in message.js.
It’s not clear whether you’ve passed an instance of Message in your tests, as I don’t see where your message variable is defined, so it’s odd that this test is passing. This description and example shows the kind of input and output intended for your rover class. You’ll see that the object rover.receiveMessge() returns has a message property that matches the name of the message passed to receiveMessage() in the above lines of code.
With rover.receiveMessage() you’re constructing an object to return based off of the message object the method receives as an argument, and the commands that message contains. With this specific test, you’re testing whether the object your method outputs contains a message property that matches the name of the message it receives as input. The test requires that you set up a message to test, pass that message to an instance of rover, and check that rover outputs an object with the properties you want.
Can you describe further what you mean by applying the objects? Do you mean working with objects, using classes to produce objects? Is there anything in particular you’re having trouble with?
Hope some of this helps!
The links given have helped significantly. Thank you so much.
Is this what I am looking for when passing message into the parameter? It technically equals the name of Message() right? I was confused because I was not sure if the code was wanting me to mention ‘object’.name instead.
This is how I tested it and it passed. I am not too sure how I am able to use .name on response. I guess it keeps ONLY the name part of the Message() function and that string alone equals the message.name passed into the parameter. Is this logic correct?
Hey @miclamb241 good questions! I removed your uploaded images though so we’re not sharing solution code. Can you rephrase your latest question without relying on these screenshots? a small portion - like a line or so - of your code is fine, just not the whole file.
When you pass the message object as the argument for your receiveMessage method, you’re granting your method access to that object via the parameter in your method’s code. Per message.js, the message object will have a name property, that’s the name you want to deal with and include in the response object the method returns.
Your ability to use .name on response relates to what goes on in your receiveMessage method, assuming you’ve assigned ‘response’ to receiveMessage(message) (or some similar return).
In that method, you’re supposed to construct an object that represents a response to the message the rover receives, and then return that object. You can go about building that object however you like, but if that return object you build in the method has a “name” property, you could then access it like so: response.name or response[“name”].
That said, I think the tests expect the message name on the return object to be associated with a property called “message” rather than “name”, but that’s an easy fix in your receiveMessage method.