javascript - Return not working as expected -
var car = function (year, make, model) { var printc = "you car is" + this.year + this.make + this.model; return printc; } var mycar = new car(2010, "hyundai", "elantra"); console.log(mycar.printc);
console.log printing undefined. why? expected output : you car 2010 hyundai elantra
var car = function (year, make, model) { var printc = "you car is" + year + make + model; return printc; } var mycar = car(2010, "hyundai", "elantra"); console.log(mycar);
Comments
Post a Comment