JSFiddle - React, Tailwind, and code Playground

by vaibhav2812

JavaScript

function Person(first, last, age, gender, interests) {
  this.name = {
    first,
    last
  };
  this.age = age;
  this.gender = gender;
  this.interests = interests;
  this.bio = function() {
  const pronoun = this.gender === 'male' ? 'he': 'she';
    alert(this.name.first + ' ' + this.name.last + ' is ' + this.age + ' years old.' + pronoun + ' likes ' + this.interests[0] + ' and ' + this.interests[1] + '.');
  };
  this.greeting = function() {
    alert('Hi! I\'m ' + this.name.first + '.');
  };
}
var person1 = new Person('Bob', 'Smith', 32, 'female', ['music', 'skiing', 'dancing']);
person1.bio();