Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Javascript: template literals not returning ${} syntax output

I am watching a YouTube video about learning javascript from some years ago, and in the video the code seems to work except on my VScode.

Here is the code, could you please let me know what I might have missed out:

function Person(firstName, lastName, dob) {
    this.firstName = firstName;
    this.lastName = lastName;
    this.dob = new Date(dob);
    this.dateBio = function() {
        return `${this.dob.getFullYear}`
    }

}

Person.prototype.fullName = function() {
    return `${this.firstName} ${this.lastName}`
}

const person1 = new Person('James','Smith', '27 July 1967');
const person2 = new Person('Mary', 'Franklin', '5 November 1991')

console.log(person1.fullName)

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

you have logged function reference only, you need to call the function.

console.log(person1.fullName())
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading