0

I am trying to invoke this function

const logPerson = (person: { name: string; age: number }) => {
    console.log('name:', person.name, 'age:', person.age);
}

I tried

let person = (_name:'Mike Pompeo', _age:'25')

But

logPerson(person)

returns

[LOG]: "name:",  undefined,  "age:",  undefined 

How to fix this?

1
  • 2
    "I tried let person = (_name:'Mike Pompeo', _age:'25') but logPerson(person) returns [LOG]: "name:", undefined, "age:", undefined." All due respect, I find that hard to believe. let person = (_name:'Mike Pompeo', _age:'25') is a syntax error as of the first : (in JavaScript) or the ) (in TypeScript). Commented Feb 18, 2021 at 10:47

1 Answer 1

1

person should be object. And also remove _ for the key name.

let person = {name:'Mike Pompeo', age:'25'}
Sign up to request clarification or add additional context in comments.

Comments

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.