JSFiddle - React, Tailwind, and code Playground

by pmamode

JavaScript

function person(firstname,lastname,age,eyecolor)
{
this.firstname=firstname;
this.lastname=lastname;
this.age=age;
this.eyecolor=eyecolor;
this.newlastname=newlastname;
function newlastname(new_lastname)
{
this.lastname=new_lastname;
}
}

myFather=new person("John","Doe",50,"blue");
myMother=new person("Sue","Smith",45,"green");

document.write(myFather.firstname + " is " + myFather.age + " years old.");
document.write(myMother.firstname + " is " + myMother.lastname + " years old.");
myMother.newlastname("Doe");
document.write(myMother.firstname + " is " + myMother.lastname + " years old.");