21 Day Coding Challenge

Code 21. Confusing


Hi folks,

Can someone who understands the last challenge give me some guidance on how to complete it?
I’ve done some coding but I know where I’m stuck.
If someone can help me, that would be really appreciative.


where are you stuck?

  • for the most part the idea is to break it down into stages.
  • remember to parse in a string when calling the broadcast function
  • and when calling the parseInt function, keep in mind that you are parsing in a hexadecimal number. so you may need to google the number you should parse as a second argument in your call
  • and finally remember to call your function to return home at the end

Me too.
What does this line mean?

You’ll need to save the response from each of these calls into it’s own variable

function returnToEarth() {
        let x = broadcast("x");
        let y = broadcast("y");
        let z = broadcast("z");

        let messageX = decodeMessage(parseInt(x, x));
        let messageY = decodeMessage(parseInt(y, y));
        let messageZ = decodeMessage(parseInt(z, z));
        navigation.x = messageX;
        navigation.y = messageY;
        navigation.z = messageZ;


This is all I’ve got @JesseKai

I’m not sure what to do in the parseInt part.


did you try parseInt(x,16)


@Sinduja like this?

 let messageX = decodeMessage(parseInt(x, 16));
 let messageY = decodeMessage(parseInt(y, 16));
 let messageZ = decodeMessage(parseInt(z, 16));

yes Thats what i tried but doesnt seem to work


nope it doesn’t work.


why am I getting this error though?

Your code could not run. Hint: "message.replace is not a function"


decodeMEssage takes a string as a input right?


I think it does. Don’t mind the other part of this comment.

  • Decode the returned message using the decodeMessage() function you wrote earlier
  • Change the decoded hex-coordinate to an integer using parseInt()

The result you get from decodeMessage() is the hex-coordinate, so you decode first, then parseInt.

let messageX = parseInt(decodeMessage(x), base);

base is the radix that represents hexadecimal.


I agree and upvote @sengakae


Don’t forget to call returnToEarth() as well!

1 Like

Thanks a lot, solved it. ALL DONE! Thanks to everyone! Cheers.


the order is wrong. put the decodeMessage function inside parseInt and then the base to make it hexidemical which is 16. and then you should use the decodeMessage() to decode the response of each broadcast function. so put that into decodeMessage function.

hope this helps

1 Like

sorry I am still confused decodeMEssage takes a string .can we pass the result of the broadcast fucntion directly to the decodeMEssage


solved tthis thanks a ton:)