Why does this JS snippet not work?

Hello all…

function Person(firstName,lastName){

    this.firstName = firstName;

    this.lastName = lastName;

    this.fullName = () => {

        const full = this.firstName + " " + this.lastName;




const brad = new Person("brad", "traversy");


when I print the output … it does not work. Can anyone explain why?

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

Note: Backticks are not single quotes.


fullName is a function. You would need to call it with brad.fullName().

1 Like

Thank you for the quick response…It worked!

I’m glad I could help. Happy coding!

1 Like