I have a method that calls “console.log”, and I invoke it inside a “console.log” call. Why do I get an extra “undefined” in the output?
05:44 17 May 2019

function Person(fname, lname) {
 this.fname = fname,
 this.lname = lname,
 this.getName = function(){
  console.log(`${fname} ${lname}`)
 }
}
var x1 = new Person("amnah", "khatun")
var x2 = new Person("xyz", "pqr")
console.log(x1.getName())

output:

amnah khatun
undefined

I m only calling x1.getName() why both are getting called and o/p coming as undefined for 2nd one. How to fix this?

javascript return console.log