2
\$\begingroup\$

I just made this simple generator as a side-project to one big project I'm working on (demo on github pages here) and would like some opinions, feedback or suggestions on how to improve it. I hope you guys like it despite it being so bad. Edit: Names added as suggested!

index.html

<!doctype html>
<html lang="en">

<head>
    <title>Couple Creator</title>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm"
        crossorigin="anonymous">

    <!--Source Bootstrap CSS-->
    <link rel="stylesheet" href="vendors/css/bootstrap.min.css">

    <!-- Font -->
    <link href="https://fonts.googleapis.com/css?family=Oregano" rel="stylesheet">

    <!-- My CSS -->
    <link rel="stylesheet" href="resources/css/main.css">

    <link rel="shortcut icon" type="image/x-icon" href="resources/img/favicon.ico">
</head>

<body>
    <div class="container text-center h-100 justify-content-center align-items-center">
        <div class="row h-100 justify-content-center align-items-center">
            <div id="box1" class="col-xl-5 box1">
                <img id="p1_image" class="profile_image" src="" alt="profile_image">
                <div id="person1">
                    <table class="table table-borderless">
                        <tbody>
                            <tr>
                                <th>Age</th>
                                <td id="p1_age"></td>
                                <th>Race</th>
                                <td id="p1_race"></td>
                            </tr>
                            <tr>
                                <th>Gender</th>
                                <td id="p1_gender"></td>
                                <th>Sexual Orientation</th>
                                <td id="p1_sexualOrientation"></td>
                            </tr>
                            <tr>
                                <th>Relationship Orientation</th>
                                <td id="p1_relationshipOrientation"></td>
                                <th>Civil Status</th>
                                <td id="p1_civilStatus"></td>
                            </tr>
                            <tr>
                                <th>Hair Color</th>
                                <td id="p1_hairColor"></td>
                                <th>Eye Color</th>
                                <td id="p1_eyeColor"></td>
                            </tr>
                            <tr>
                                <th>Profession</th>
                                <td id="p1_profession"></td>
                                <th>Social class</th>
                                <td id="p1_socialClass"></td>
                            </tr>
                            <tr>
                                <th>Children</th>
                                <td id="p1_children"></td>
                                <th>Pets</th>
                                <td id="p1_pets"></td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
            <div class="col-xl-2">
                <div class="btn_div">
                    <button type="button" id="btn_couple_creator" class="btn btn-lg btn-outline-danger">Create Couple</button>
                </div>
            </div>
            <div id="box2" class="col-xl-5 box2">
                <img id="p2_image" class="profile_image" src="" alt="profile_image">
                <div id="person2">
                    <table class="table table-borderless">
                        <tbody>
                            <tr>
                                <th>Age</th>
                                <td id="p2_age"></td>
                                <th>Race</th>
                                <td id="p2_race"></td>
                            </tr>
                            <tr>
                                <th>Gender</th>
                                <td id="p2_gender"></td>
                                <th>Sexual Orientation</th>
                                <td id="p2_sexualOrientation"></td>
                            </tr>
                            <tr>
                                <th>Relationship Orientation</th>
                                <td id="p2_relationshipOrientation"></td>
                                <th>Civil Status</th>
                                <td id="p2_civilStatus"></td>
                            </tr>
                            <tr>
                                <th>Hair Color</th>
                                <td id="p2_hairColor"></td>
                                <th>Eye Color</th>
                                <td id="p2_eyeColor"></td>
                            </tr>
                            <tr>
                                <th>Profession</th>
                                <td id="p2_profession"></td>
                                <th>Social class</th>
                                <td id="p2_socialClass"></td>
                            </tr>
                            <tr>
                                <th>Children</th>
                                <td id="p2_children"></td>
                                <th>Pets</th>
                                <td id="p2_pets"></td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>

    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="vendors/js/jquery-3.3.1.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q"
        crossorigin="anonymous"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl"
        crossorigin="anonymous"></script>

    <!-- Source Bootstrap JS-->
    <script src="vendors/js/bootstrap.min.js"></script>

    <!-- My JS -->
    <script src="resources/js/person_img.js"></script>
    <script src="resources/js/main.js"></script>

    <script>

        $(document).ready(function () {
            $("#btn_couple_creator").click(function () {
                var couple = createCouple();
                $("#box1").fadeOut(300, function () {
                    generatePerson1(couple);
                    $(this).fadeIn(300);
                });
                $("#box2").fadeOut(300, function () {
                    generatePerson2(couple);
                    $(this).fadeIn(300);
                });
            });
        });

        function generatePerson1(couple) {
            $("#p1_image").attr("src", "resources/img/" + couple[0].image);
            $("#p1_race").html(couple[0].race);
            $("#p1_gender").html(couple[0].fullGender);
            $("#p1_age").html(couple[0].age);
            $("#p1_sexualOrientation").html(couple[0].sexualOrientation);
            $("#p1_relationshipOrientation").html(couple[0].relationshipOrientation);
            $("#p1_civilStatus").html(couple[0].civilStatus);
            $("#p1_profession").html(couple[0].profession);
            $("#p1_socialClass").html(couple[0].socialClass);
            $("#p1_hairColor").html(couple[0].hairColor);
            $("#p1_eyeColor").html(couple[0].eyeColor);
            $("#p1_children").html(couple[0].children);
            $("#p1_pets").html(couple[0].pets);
        }

        function generatePerson2(couple) {
            $("#p2_image").attr("src", "resources/img/" + couple[1].image);
            $("#p2_race").html(couple[1].race);
            $("#p2_gender").html(couple[1].fullGender);
            $("#p2_age").html(couple[1].age);
            $("#p2_sexualOrientation").html(couple[1].sexualOrientation);
            $("#p2_relationshipOrientation").html(couple[1].relationshipOrientation);
            $("#p2_civilStatus").html(couple[1].civilStatus);
            $("#p2_profession").html(couple[1].profession);
            $("#p2_socialClass").html(couple[1].socialClass);
            $("#p2_hairColor").html(couple[1].hairColor);
            $("#p2_eyeColor").html(couple[1].eyeColor);
            $("#p2_children").html(couple[1].children);
            $("#p2_pets").html(couple[1].pets);
        }

    </script>
</body>

</html>

main.css

html{
    min-height: 100%;
}

body{
    height: 100%;
    font-family: 'Oregano', sans-serif;
    font-size: .7em;
    background-image:url("../img/background.jpg");
    background-size: cover;
    background-repeat: no-repeat;
}

.container {
    text-align: center;
    margin: 3% auto;
}

.btn_div{
    text-align: center;
}

.btn-lg {
    border-radius: 100%;
    padding: 10%;
    margin: 5% auto;
    font-size:1.4em;
}

.box1, .box2{
    padding:2%;
    background-color: #dc35454a;
    width:100%;
    height:auto;
    display:none;
    margin: auto 3%;
}

.profile_image{
    max-width:100%;
    max-height: 300px;
    text-align: center;
    margin: 0 auto;
    display: block;
    margin-bottom:2%;
    border-radius:3%;
}

@media (min-width: 576px) {
    .btn-lg {
        width:auto;
        padding: 7%;
        font-size: 1.5em;
    }
    body{
        font-size: 1.3em;
    }
    .box1, .box2{
        min-height:812.59px;
        margin: auto auto;
    }
 }

 @media (min-width: 992px) {
    body{
        font-size: 1.5em;
    }
    .btn-lg {
        padding: 7%;
        font-size: 1.3em;
    }
    .box1, .box2{
        min-height:754.17px;
    }
  }

  @media (min-width: 1200px) {
    body{
        font-size: 1em;
        position:relative;
    }
    .btn-lg {
        padding: 14%;
        font-size: 1.3em;
    }
    .box1, .box2{
        min-height:754.17px;
    }
  }

main.js

/* HELPER FUNCTIONS */

function getRandomItem(obj) {
    return getRandomValue(Object.values(obj));
}

function getRandomValue(arr) {
    return arr[Math.floor(Math.random() * arr.length)];
}

function range(start, end) {
    return Array(end - start + 1).fill().map((_, idx) => start + idx)
}

function convertNumToWord(num) {
    switch (num) {
        case 0:
            return "none";
        case 1:
            return "one";
        case 2:
            return "two";
        case 3:
            return "three";
        case 4:
            return "four";
        default:
            throw "Number not valid.";
    }
}

function capitalizeFirstLetter(str) {
    return str.charAt(0).toUpperCase() + str.slice(1);
}

function makePlural(num, str) {
    if (num > 1) {
        return str + 's';
    }
    return str;
}

/* CONSTANT VARIABLES */

Professions = [
    "Actor",
    "Athlete",
    "Archeologist",
    "Architect",
    "Artist",
    "Audiovisual Technician",
    "Author",
    "Baker",
    "Bookkeeper",
    "Cartographer",
    "Cashier",
    "Chef",
    "Chemist",
    "Dancer",
    "Dentist",
    "Designer",
    "Doctor",
    "Economist",
    "Editor",
    "Electrician",
    "Engineer",
    "Farmer",
    "Firefighter",
    "Fisher",
    "Hairdresser",
    "Historian",
    "Illustrator",
    "Lawyer",
    "Musician",
    "Nutritionist",
    "Obstetrician",
    "Office clerk",
    "Painter",
    "Pharmacist",
    "Physician",
    "Podiatrist",
    "Police officer",
    "Politician",
    "Preschool teacher",
    "Producer",
    "Psychiatrist",
    "Psychologist",
    "Receptionist",
    "Registered nurse",
    "Sailor",
    "Sales manager",
    "Secondary school teacher",
    "Secretary",
    "Security guard",
    "Singer",
    "Social worker",
    "Sociologist",
    "Sociology teacher",
    "Software developer",
    "Software engineer",
    "Space scientist",
    "Sports entertainer",
    "Sports performer",
    "Statistician",
    "Surgeon",
    "Taxi driver",
    "Teacher assistant",
    "Teacher",
    "Veterinarian",
    "Writer",
    "Zoologist"
];

Races = (function () {
    var obj = {};
    obj.BLACK = 'Black';
    obj.WHITE = 'White';
    obj.ASIAN = 'Asian';
    return obj;
})();

HairColors = (function () {
    var obj = {};
    obj.BROWN = 'Brown';
    obj.BLOND = 'Blond';
    obj.RED = 'Red';
    obj.GRAY = 'Gray';
    return obj;
})();

EyeColors = (function () {
    var obj = {};
    obj.BROWN = 'Brown';
    obj.BLUE = 'Blue';
    obj.GREEN = 'Green';
    return obj;
})();

Genders = (function () {
    var obj = {};
    obj.MALE = 'Male';
    obj.FEMALE = 'Female';
    obj.NONBINARY = 'Non-binary';
    return obj;
})();

GenderIdentities = (function () {
    var obj = {};
    obj.CIS = 'Cisgender';
    obj.TRANS = 'Transgender';
    return obj;
})();

RelationshipOrientations = (function () {
    var obj = {};
    obj.MONOAMOROUS = 'Monoamorous';
    obj.POLYAMOROUS = 'Polyamorous';
    return obj;
})();

CivilStatus = (function () {
    var obj = {};
    obj.SINGLE = 'Single';
    obj.DIVORCED = 'Divorced';
    obj.WIDOWED = 'Widowed';
    obj.MARRIED = 'Married';
    return obj;
})();

Nums = [0, 1, 2, 3, 4];

Pets = (function () {
    var obj = {};
    obj.CAT = "cat";
    obj.DOG = "dog";
    obj.RABBIT = "rabbit";
    obj.BIRD = "bird";
    return obj;
})();

SocialClasses = (function () {
    var obj = {};
    obj.LOW = "Lower class";
    obj.MIDDLE = "Middle class";
    obj.HIGH = "Upper class";
    return obj;
})();


SexualOrientations = (function () {
    var obj = {};

    // Main orientations
    obj.HETEROSEXUAL = 'Heterosexual';
    obj.BISEXUAL = 'Bisexual/Pansexual';
    obj.HOMOSEXUAL = 'Homosexual';
    obj.ASEXUAL = 'Asexual';
    // Nonbinary orientations
    obj.ANDROSEXUAL = 'Androsexual';
    obj.GYNESEXUAL = 'Gynesexual';
    // Asexual orientations
    obj.HETEROROMANTIC_ASEXUAL = 'Heteroromantic Asexual';
    obj.BIROMANTIC_ASEXUAL = 'Biromantic/Panromantic Asexual';
    obj.HOMOROMANTIC_ASEXUAL = 'Homoromantic Asexual';
    // Nonbinary asexual orientations
    obj.ANDROROMANTIC_ASEXUAL = 'Androromantic Asexual';
    obj.GYNEROMANTIC_ASEXUAL = 'Gyneromantic Asexual';

    return obj;
})();

// Binary
BinaryOrientations = [SexualOrientations.HETEROSEXUAL, SexualOrientations.BISEXUAL, SexualOrientations.HOMOSEXUAL, SexualOrientations.ASEXUAL];
StraightOrientations = [SexualOrientations.HETEROSEXUAL, SexualOrientations.HETEROROMANTIC_ASEXUAL];
BiOrientations = [SexualOrientations.BISEXUAL, SexualOrientations.BIROMANTIC_ASEXUAL];
GayOrientations = [SexualOrientations.HOMOSEXUAL, SexualOrientations.HOMOROMANTIC_ASEXUAL];
AsexualBinaryOrientations = [SexualOrientations.HETEROROMANTIC_ASEXUAL, SexualOrientations.BIROMANTIC_ASEXUAL, SexualOrientations.HOMOROMANTIC_ASEXUAL];
StraightAndBiOrientations = [...StraightOrientations, ...BiOrientations];
GayAndBiOrientations = [...GayOrientations, ...BiOrientations];

// Nonbinary
NonbinaryOrientations = [SexualOrientations.ANDROSEXUAL, SexualOrientations.GYNESEXUAL, SexualOrientations.BISEXUAL, SexualOrientations.ASEXUAL];
AndroOrientations = [SexualOrientations.ANDROSEXUAL, SexualOrientations.ANDROROMANTIC_ASEXUAL];
GyneOrientations = [SexualOrientations.GYNESEXUAL, SexualOrientations.GYNEROMANTIC_ASEXUAL];
AsexualNonbinaryOrientations = [SexualOrientations.ANDROROMANTIC_ASEXUAL, SexualOrientations.GYNEROMANTIC_ASEXUAL, SexualOrientations.BIROMANTIC_ASEXUAL];

/* GET RANDOM PROPRERTIES */

function getNumOfPets() {
    return getRandomValue(Nums);
}

function getTypeOfPets() {
    var types = [];
    var numOfPets = getNumOfPets();
    for (var i = 0; i < numOfPets; i++) {
        var pet = getRandomItem(Pets);
        types.push(pet);
    }
    return types;
}

function getPetCount(arr) {
    arr.sort();
    var currentPet = null;
    var count = 0;
    var petsArr = [];
    for (var i = 0; i < arr.length; i++) {
        if (arr[i] != currentPet) {
            if (count > 0) {
                petsArr.push([count, currentPet]);
            }
            currentPet = arr[i];
            count = 1;
        } else {
            count++;
        }
    }
    if (count > 0) {
        petsArr.push([count, currentPet]);
    }
    return petsArr;
}

function getPets() {
    var arr = getTypeOfPets();
    var petsArr = getPetCount(arr);
    var pets = '';
    for (var i = 0; i < petsArr.length; i++) {
        petsArr[i][1] = makePlural(petsArr[i][0], petsArr[i][1]);
        petsArr[i][0] = convertNumToWord(petsArr[i][0]);
        if (i + 1 == petsArr.length) {
            pets += petsArr[i][0] + ' ' + petsArr[i][1];
        }
        else if (i + 2 == petsArr.length) {
            pets += petsArr[i][0] + ' ' + petsArr[i][1] + ' and ';
        }
        else if (i + 3 >= petsArr.length) {
            pets += petsArr[i][0] + ' ' + petsArr[i][1] + ', ';
        }
    }
    if (pets.length == 0) {
        return 'None';
    }
    return capitalizeFirstLetter(pets);
}

function getChildren(age) {
    // People younger than 25 have no children
    if (age < 25) {
        return "None";
    }
    var num = getRandomValue(Nums);
    // People younger than 28 can have 2 children at most
    if (age < 28) {
        while (num >= 3) {
            num = getRandomValue(Nums);
        }
    }
    return capitalizeFirstLetter(convertNumToWord(num));
}

function getCivilStatus(age, relationshipOrientation) {
    // People younger than 25 are single by default.
    if (age < 25) {
        return CivilStatus.SINGLE;
    }
    // Poly people can be Married.
    if (relationshipOrientation == RelationshipOrientations.POLYAMOROUS) {
        return getRandomItem(CivilStatus);
    }
    // Mono people cannot be Married.
    var status = getRandomItem(CivilStatus);
    while (status == CivilStatus.MARRIED) {
        status = getRandomItem(CivilStatus);
    }
    return status;
}

function getSocialClass() {
    return getRandomItem(SocialClasses);
}

function getAge() {
    return getRandomValue(range(18, 69));
}

function getGender() {
    return getRandomItem(Genders);
}

function getGenderIdentity(gender) {
    // Nonbinary people are automatically trans.
    if (gender == Genders.NONBINARY) {
        return GenderIdentities.TRANS;
    }
    return getRandomItem(GenderIdentities);
}

function getFullGender(gender, genderIdentity) {
    // Specify gender - and gender identity if transgender (excluding nonbinary)
    if (gender != Genders.NONBINARY && genderIdentity == GenderIdentities.TRANS) {
        return gender + " (" + genderIdentity + ")";
    }
    return gender;
}

function getSexualOrientation(gender) {
    var orientation;
    if (gender == Genders.NONBINARY) {
        orientation = getRandomValue(NonbinaryOrientations);
    }
    else {
        orientation = getRandomValue(BinaryOrientations);
    }
    if (orientation == SexualOrientations.ASEXUAL) {
        if (gender == Genders.NONBINARY) {
            orientation = getRandomValue(AsexualNonbinaryOrientations);
        } else {
            orientation = getRandomValue(AsexualBinaryOrientations);
        }
    }
    return orientation;
}

function getRelationshipOrientation() {
    return getRandomItem(RelationshipOrientations);
}

function getHairColor() {
    var color = getRandomItem(HairColors);
    // Gray hair not allowed at first
    while (color == HairColors.GRAY) {
        color = getRandomItem(HairColors);
    }
    return color;
}

function getEyeColor() {
    return getRandomItem(EyeColors);
}

function getRace() {
    return getRandomItem(Races);
}

function getProfession() {
    return getRandomValue(Professions);
}

/* PERSON CLASSES */

var Person = function () {
    this.race = getRace();
    this.hairColor = getHairColor();
    this.eyeColor = getEyeColor();
    this.relationshipOrientation = getRelationshipOrientation();
    this.profession = getProfession();
    this.socialClass = getSocialClass();
    this.pets = getPets();
}

var Person1 = function () {
    Person.call(this);
    this.gender = getGender();
    this.genderIdentity = getGenderIdentity(this.gender);
    this.fullGender = getFullGender(this.gender, this.genderIdentity);
    this.age = getAge();
    this.children = getChildren(this.age);
    this.civilStatus = getCivilStatus(this.age, this.relationshipOrientation);
    this.sexualOrientation = getSexualOrientation(this.gender);
    this.image = getImage(this);
}

var Person2 = function (person1) {
    Person.call(this);
    this.gender = getCompatibleGender(person1);
    this.genderIdentity = getGenderIdentity(this.gender);
    this.fullGender = getFullGender(this.gender, this.genderIdentity);
    this.age = getCompatibleAge(person1);
    this.children = getChildren(this.age);
    this.sexualOrientation = getCompatibleOrientation(this.gender, person1);
    this.civilStatus = getCivilStatus(this.age, this.relationshipOrientation);
    this.image = getImage(this);
}

/* ACTION FUNCTIONS */

function createCouple() {
    var person1 = new Person1();
    var person2 = new Person2(person1);
    switchCharacteristics([person1, person2]);
    return [person1, person2];
}

function switchCharacteristics(persons) {
    for (var i = 0; i < persons.length; i++) {
        if (persons[i].age < 25) {
            persons[i].profession = "Student";
        }
        if (persons[i].age > 49) {
            persons[i].hairColor = HairColors.GRAY;
        }
        if (persons[i].age > 64) {
            persons[i].profession = persons[i].profession + ' (Retired)';
        }
    }
}

/* GET COMPATIBLE CHARACTERISTICS */

function getCompatibleGender(person1) {
    // First, determine person2's same/opposite genders.
    var same, opposite;
    if (person1.gender == Genders.MALE) {
        same = Genders.MALE;
        opposite = Genders.FEMALE;
    }
    else if (person1.gender == Genders.FEMALE) {
        same = Genders.FEMALE;
        opposite = Genders.MALE;
    }
    else {
        if (AndroOrientations.includes(person1.sexualOrientation)) {
            return Genders.MALE;
        }
        if (GyneOrientations.includes(person1.sexualOrientation)) {
            return Genders.FEMALE;
        }
    }
    // Then return gender based on person1's sexual orientation
    if (StraightOrientations.includes(person1.sexualOrientation)) {
        return opposite;
    }
    else if (BiOrientations.includes(person1.sexualOrientation)) {
        return getRandomItem(Genders);
    }
    else {
        return same;
    }
}

function getCompatibleOrientation(gender, person1) {
    // Automatically return Bi if person1's gender is non-binary
    if (person1.gender == Genders.NONBINARY) {
        return getRandomValue(BiOrientations);
    }
    // Else return orientation based on person1's orientation
    if (StraightOrientations.includes(person1.sexualOrientation)) {
        return getRandomValue(StraightAndBiOrientations);
    }
    else if (GayOrientations.includes(person1.sexualOrientation)) {
        return getRandomValue(GayAndBiOrientations);
    }
    else {
        if (gender == person1.gender) {
            return getRandomValue(GayAndBiOrientations);
        }
        return getRandomValue(StraightAndBiOrientations);
    }
}

function getCompatibleAge(person1) {
    if (person1.age < 30) {
        return getRandomValue(range(18, 29));
    }
    if (person1.age < 50) {
        return getRandomValue(range(30, 49));
    }
    return getRandomValue(range(51, 69));
}

person_img.js

function getImage(person) {
    if (person.race == Races.WHITE) {
        return get_white_person_img(person);
    }
    if (person.race == Races.BLACK) {
        return get_black_person_img(person);
    }
    if (person.race == Races.ASIAN) {
        return get_asian_person_img(person);
    }
}

function get_white_person_img(person) {
    if (person.gender == Genders.MALE) {
        return get_white_male_img(person);
    }
    if (person.gender == Genders.FEMALE) {
        return get_white_female_img(person);
    }
    return get_white_nonbinary_img(person);
}

function get_black_person_img(person) {
    if (person.gender == Genders.MALE) {
        return get_black_male_img(person);
    }
    if (person.gender == Genders.FEMALE) {
        return get_black_female_img(person);
    }
    return get_black_nonbinary_img(person);
}

function get_asian_person_img(person) {
    if (person.gender == Genders.MALE) {
        return get_asian_male_img(person);
    }
    if (person.gender == Genders.FEMALE) {
        return get_asian_female_img(person);
    }
    return get_asian_nonbinary_img(person);
}

function get_white_male_img(person) {
    if (person.age < 30) {
        if (person.hairColor == HairColors.BROWN) {
            return "colin_morgan.jpg";
        }
        if (person.hairColor == HairColors.BLOND) {
            return "dane_dehaan.jpg";
        }
        if (person.hairColor == HairColors.RED) {
            return "cameron_monaghan.jpg";
        }
    }
    if (person.age < 50) {
        if (person.hairColor == HairColors.BROWN) {
            return "benedict_cumberbatch.jpg";
        }
        if (person.hairColor == HairColors.RED) {
            return "damian_lewis.jpg";
        }
        if (person.hairColor == HairColors.BLOND) {
            return "james_norton.jpg";
        }
    }
    return "hugh_laurie.jpg";
}

function get_white_female_img(person) {
    if (person.age < 30) {
        if (person.hairColor == HairColors.BLOND && person.eyeColor == EyeColors.BLUE) {
            return "jennifer_lawrence.jpg";
        }
        if (person.hairColor == HairColors.RED && person.eyeColor == EyeColors.BROWN) {
            return "elçin_sangu.jpg";
        }
        if (person.hairColor == HairColors.BLOND && person.eyeColor == EyeColors.GREEN) {
            return "dianna_agron.jpg";
        }
        if (person.hairColor == HairColors.RED && person.eyeColor == EyeColors.GREEN) {
            return "emma_stone.jpg";
        }
        if (person.hairColor == HairColors.RED && person.eyeColor == EyeColors.BLUE) {
            return "shopie_turner.jpg";
        }
        if (person.hairColor == HairColors.BROWN && person.eyeColor == EyeColors.GREEN) {
            return "felicity_jones.jpg";
        }
        if (person.hairColor == HairColors.BROWN && person.eyeColor == EyeColors.BLUE) {
            return "unknown_white_girl.jpg";
        }
        if (person.hairColor == HairColors.BROWN && person.eyeColor == EyeColors.BROWN) {
            return "stacy_martin.jpg";
        }
        if (person.hairColor == HairColors.BLOND && person.eyeColor == EyeColors.BROWN) {
            return "alona_tal.jpg";
        }
    }
    if (person.age < 50) {
        if (person.hairColor == HairColors.BROWN) {
            return "lena_headey.jpg";
        }
        if (person.hairColor == HairColors.BLOND) {
            return "vera_fermiga.jpg"
        }
        if (person.hairColor == HairColors.RED) {
            return "nicole_kidman.jpg"
        }
    }
    return "unknown_old_woman.jpg";
}

function get_white_nonbinary_img(person) {
    if (person.age < 30) {
        if (person.hairColor == HairColors.BROWN) {
            return "asia_kate_dillon.jpg";
        }
        if (person.hairColor == HairColors.RED) {
            return "kaitlyn_alexander.jpg";
        }
        if (person.hairColor == HairColors.BLOND) {
            return "nevo_zisin.jpg";
        }
    }
    if (person.age < 50) {
        if (person.hairColor == HairColors.BROWN) {
            return "cillian_murphy.jpg";
        }
        if (person.hairColor == HairColors.BLOND) {
            return "unknown_androgynous_man.jpg";
        }
        if (person.hairColor == HairColors.RED) {
            return "freya_autumn.jpg";
        }
    }
    return "tilda_swinton.jpg";
}

function get_black_male_img(person) {
    if (person.age < 30) {
        if (person.hairColor == HairColors.BROWN) {
            return "corbin_bleu.jpg";
        }
        if (person.hairColor == HairColors.BLOND) {
            return "jaden_smith.jpg";
        }
        if (person.hairColor == HairColors.RED) {
            return "sean_denizard.jpg";
        }
    }
    if (person.age < 50) {
        if (person.hairColor == HairColors.BROWN) {
            return "will_smith.jpg";
        }
        if (person.hairColor == HairColors.RED) {
            return "vernon_françois.jpg";
        }
        if (person.hairColor == HairColors.BLOND) {
            return "sisqo.jpg";
        }
    }
    return "morgan_freeman.jpg";
}

function get_black_female_img(person) {
    if (person.age < 30) {
        if (person.hairColor == HairColors.BLOND) {
            return "jaz_sinclair.jpg";
        }
        if (person.hairColor == HairColors.BROWN) {
            return "aja_naomi_king.jpg";
        }
        if (person.hairColor == HairColors.RED) {
            return "unknown_black_ginger.jpg";
        }
    }
    if (person.age < 50) {
        if (person.hairColor == HairColors.BLOND) {
            return "laverne_cox.jpg";
        }
        if (person.hairColor == HairColors.BROWN) {
            return "viola_davis.jpg";
        }
        if (person.hairColor == HairColors.RED) {
            return "yvonne_okoro.jpg";
        }
    }
    return "poze_ruby_dee.jpg";
}

function get_black_nonbinary_img(person) {
    if (person.age < 30) {
        if (person.hairColor == HairColors.BROWN) {
            return "tyler_ford.jpg";
        }
        if (person.hairColor == HairColors.RED) {
            return "black_ginger_androgynous_actress.jpg";
        }
        if (person.hairColor == HairColors.BLOND) {
            return "unknown_black_androgynous_actor_blond.jpg";
        }
    }
    if (person.age < 50) {
        if (person.hairColor == HairColors.BROWN) {
            return "unknown_androgynous_black.jpg";
        }
        if (person.hairColor == HairColors.RED) {
            return "rihanna.jpg";
        }
        if (person.hairColor == HairColors.BLOND) {
            return "liya_kebede.jpg";
        }
    }
    return "black_old_androgynous_actress.jpg";
}

function get_asian_male_img(person) {
    if (person.age < 30) {
        if (person.hairColor == HairColors.BROWN) {
            return "unknown_asian_actor.jpg";
        }
        if (person.hairColor == HairColors.BLOND) {
            return "kim_jaejoong.jpg";
        }
        if (person.hairColor == HairColors.RED) {
            return "unknown_asian_actor2.jpg";
        }
    }
    if (person.age < 50) {
        if (person.hairColor == HairColors.BROWN) {
            return "unknown_asian_actor3.jpg";
        }
        if (person.hairColor == HairColors.RED) {
            return "unknown_ginger_asian_man.jpg";
        }
        if (person.hairColor == HairColors.BLOND) {
            return "unknown_blond_asian_man.jpg";
        }
    }
    return "jackie_chan.jpg";
}
function get_asian_female_img(person) {
    if (person.age < 30) {
        if (person.hairColor == HairColors.RED) {
            return "unknown_asian_girl.jpg";
        }
        if (person.hairColor == HairColors.BROWN) {
            return "keiko_kitagawa.jpg";
        }
        if (person.hairColor == HairColors.BLOND) {
            return "stellar_hyoeun.jpg";
        }
    }
    if (person.age < 50) {
        if (person.hairColor == HairColors.RED) {
            return "unknown_asian_woman_ginger.jpg";
        }
        if (person.hairColor == HairColors.BROWN) {
            return "lucy_liu.jpg";
        }
        if (person.hairColor == HairColors.BLOND) {
            return "unknown_blond_asian_woman.jpg";
        }
    }
    return "unknown_asian_old_woman.jpg";
}
function get_asian_nonbinary_img(person) {
    if (person.age < 30) {
        if (person.hairColor == HairColors.RED) {
            return "seungho.jpg";
        }
        if (person.hairColor == HairColors.BROWN) {
            return "liu_li_yang.jpg";
        }
        if (person.hairColor == HairColors.BLOND) {
            return "sooJoo_park.jpg";
        }
    }
    if (person.age < 50) {
        if (person.hairColor == HairColors.BROWN) {
            return "whiterose.jpg";
        }
        if (person.hairColor == HairColors.BLOND) {
            return "yoshi_sudarso.jpg";
        }
        if (person.hairColor == HairColors.RED) {
            return "unknown_androgynous_woman.jpg";
        }
    }
    return "androgynous_asian_old_woman.jpg";
}
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.