JSFiddle - React, Tailwind, and code Playground
by mrunali tatkundawar
JavaScript
function Employee(first, last, age, gender, interests, company, position, Experience) {
this.name = {
first,
last
};
this.age = age;
this.gender = gender;
this.interests = interests;
this.company = company;
this.position = position;
this.Experience = Experience;
};
Employee.prototype.bio = function() {
//var string = this.name.first + ' ' + this.name.last + ' is ' + this.age + ' years old. ';
var string = this.name.first + ' ' + this.name.last + ' ' + 'working in a ' + this.company + ' ' + 'company ' + 'as a' + this.position + '.'
var pronoun;
if (this.gender === 'male' || this.gender === 'Male' || this.gender === 'm' || this.gender === 'M') {
pronoun = 'He likes ';
} else if (this.gender === 'female' || this.gender === 'Female' || this.gender === 'f' || this.gender === 'F') {
pronoun = 'She likes ';
} else {
pronoun = 'They like ';
}
string += pronoun;
if (this.interests.length === 1) {
string += this.interests[0] + '.';
} else if (this.interests.length === 2) {
string += this.interests[0] + ' and ' + this.interests[1] + '.';
} else {
for (var i = 0; i < this.interests.length; i++) {
if (i === this.interests.length - 1) {
string += 'and ' + this.interests[i] + '.';
} else {
string += this.interests[i] + ', ';
}
}
}
alert(string);
Employee1.birthyear();
Employee1.noExp();
Employee1.farewell();
};
Employee.prototype.introduction = function() {
alert('Hi! I\'m ' + this.name.first + '.');
};
Employee.prototype.farewell = function() {
Employee1.introduction();
alert(this.name.first + ' has left the building. Bye for now!');
}
Employee.prototype.birthyear = function() {
var currentyear = new Date().getFullYear();
alert('I am born in the year ' + (currentyear - this.age));
}
Employee.prototype.noExp = function() {
var currentyear = new Date().getFullYear();
alert(currentyear - this.Experience);
}
var Employee1 = new Person('Mayuri',...