0

My code works and outputs "This is Bob Martin from USA."

However, I want my code to: 1.) Have function printBio(user) return a string. The return value from the function should be a string. And 2.) Should convert object into a string with the structure: "This is NAME SURNAME from COUNTRY." function should convert the user object into a properly formatted string and then return that string

function printBio (user) {
  
  user = { 
  name: 'Bob',
  surname: 'Martin',
  age: 25,
  address: {
    country: "USA"
  }
}

console.log(`This is ${user.name} ${user.surname} from ${user.address.country}.`);
  return user;
  
}
printBio();

1 Answer 1

1

I don't understand the problem as you already did make a template, but this is your code rearanged.

const user = {
  name: 'Bob',
  surname: 'Martin',
  age: 25,
  address: {
    country: "USA"
  }
}

function printBio(user) {

  return `This is ${user.name} ${user.surname} from ${user.address.country}.`
}

const bio = printBio(user);

console.log(bio)

Sign up to request clarification or add additional context in comments.

1 Comment

You actually solved it for me. It was the last 2 lines, Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.