Challenge 2 Megathread

Welcome to challenge #2!

Use this thread for any and all questions relating to challenge 2.


Why is updating the value for the object not working for me?

This is my code for updating →

exampleAstronaut.prefix = "Astronaut";
exampleAstronaut.firstName = "Neil";
exampleAstronaut.lastName = "Armstrong";
exampleAstronaut.nickName = "Steps"

return exampleAstronaut.prefix + ": " + exampleAstronaut.firstName + ’ “’ + exampleAstronaut.nickName + '” ’ + exampleAstronaut.lastName

And this is my error →

Looks like the values are hardcoded for the object exampleAstronaut and you are outputting those values. The return statement is correct, but the values feeding it is incorrect. Use the parameters supplied by the function.

1 Like

@Abida You have to return the string from inside the function. Inside the function the object is available as parameter astronaut not exampleAstronaut.

Hello, I am not able to see challenge #2 in my account. Pls, help.

Hi there aatreyapurapu_lhl !

You did not complete the first challenge yet, so you don’t have access to the second one yet.

I submitted the code yesterday itself… Now I don’t have an option of submitting the code again.

Hey, I completed this challenge yesterday when it was open, but now if I go on my challenges it shows it as not completed and I do not have a submit button. Could you please help?

Ok, I’ll have a look at you and Alex’s code, should be available soon

Alex & Aatreya, it should work properly now, can you try again?

Just an FYI, like the first challenge, your input information is provided. No need to redeclare the input data. If you want to see what it looks like run → console.log(astronaut)

Also, no need to worry about a long return statement! Just press enter to move to a new line. It doesn’t break up the code.


Yes, now I can see challenge #2, thank you.

1 Like

Heyo, I have the same (or a similar issue). This challenge was made available to me yesterday and I completed it. It now looks like it is incomplete but all I have are the test and discuss buttons available. Not sure how I can and should submit again.


I seem to have trouble with the challenge. This is my current code:

const generateAstronautTag = (astronaut) => {
  // Code here!
        firstName= 'Astronaut';
        nickname= 'Steps';
        prefix= 'Armstrong';
        let output= (`${prefix}: ${firstName} "${nickname}" ${lastName}`)
return (output)
  // Remember to return a value!

However, while this succeeds the first test and the first part of the second text, it fails the second part of the test.

Does anyone have insight?

@WerrerRealm, first see what the provided code outputs using:

Review the output in the console and this may help to determine the proper output.


Upon doing this, the console would then return that prefix is undefined. Should I still have some sort of firstName= blank or something?

the astronaut parameter is an object. You can access the value by key something like this: astrounaut.firstName

Quick Q:
Is it expecting both Cosmo/Astro outputs or just one or the other. Or are we to update the Cosmo with Astro, vv? Not sure if I understand the question right?

With only the one line


in the code you’re getting an error about the prefix? You should be seeing a response like this in your console:

Running test: The generateAstronautTag function should return a string


Running test: The generateAstronautTag function should return the string in the proper format


Hi there,

The challenge will pass an astronaut as an object to the function with a firstName, lastName, nickname and prefix, so you do not have to create an astronaut, rather you need to be able to access the properties of the astronaut object (e.g., firstName) passed to the function.

Check out this resource on how to access properties of an object.

Your use of template literals\strings is looking good!

1 Like