Task using OOPS

Task using OOPS

Write a JS function that display the bio data (firstName, LastName, age,email) of 3 Persons as shown in table

PersonFirst NameLast NameAgeEmail
Person 1ShairyKalra32er.shairykalra@gmail.com
Person 2Etudepro
Person 3Dummy Name25

Solutions:

<script>
class Person {
        constructor(firstName, lastName, age, email)
		{
            this.firstName = firstName;
            this.lastName = lastName;
            this.age = age;
            this.email = email;
        }
		Display()
		{
			document.write("First Name :"+this.firstName+"<br>");
			document.write(" Last Name :"+this.lastName+"<br>");
			document.write("Age :"+this.age+"<br>");
			document.write("Email :"+this.email+"<br>");
			document.write("<hr>");
			
        }
    }
let object1=new Person("Shairy", "Kalra", 32, "er.shairykalra@gmail.com");
object1.Display();
let object2=new Person("Etudepro");
object2.Display();
let object3=new Person("Dummy Name","", 25);
object3.Display();

</script>

Post Your Comments & Reviews

Your email address will not be published. Required fields are marked *

*

*