Mixed Messages(but not really)

Hello all! This is my first post!
I really enjoyed doing this project, I feel like it really pulled together all of the concepts that we had worked on to this point.

I know that the project asked for messages of some kind, but I chose to use the same overall concept and just change it to generate a random 3v3 NBA Team, since that interested me a lot more than the other prompts.

My program saves the top ten (objectively) NBA players by position (point guard, small forward, and center) into an object.

We then iterate over the objects properties and return an array with a 3 person team, one player from each property selected randomly.

Lastly, it displays to the console the team in as pretty of a format as I could come up with. (not the most creative in console)

Below is a link to the repository on github:
NBA 3v3 Generator

Here is the code if you don’t feel like looking there!

//function to generate random number accepts num as param
const generateRandomNumber = num => Math.floor(Math.random() * num); 

//three player team object has 3 properties with array of top ten players in each category
const threePlayerTeam = {
    pg: ["Luka Doncic", "Damian Lillard", "Stephen Curry", "Ben Simmons", "Russell Westbrook",
        "Kyrie Irving", "Jamal Murray", "Ja Morant", "Trae Young", "De'Aaron Fox"], 
    sf: ["LeBron James", "Kawhi Leonard", "Jimmy Butler", "Khris Middleton", "Jayson Tatum",
        "Brandon Ingram", "Gordon Hayward", "DeMar DeRozan", "Will Barton", "Bojan Bogdanovic"],
    center: ["Nikola Jokic", "Joel Embiid", "Karl Anthony Towns", "Rudy Gobert", "Bam Adebayo",
        "Kristaps Porzingis", "Jusuf Nurkic", "Nikola Vucevic", "DeAndre Ayton", "Jonas Valanciunas"]
}; 

//accepts a object of arrays, loops through each prop and selects random player from array, pushes to team array
const generateTeam = teamObject => {
    let team = []
    for(let property in teamObject) {
        team.push(teamObject[property][generateRandomNumber(teamObject[property].length)])
    }
    return team;  
};

//display team array for testing purposes
const displayTeam = team => {
    console.log("\n\n*****NBA 3V3 TEAM GENERATOR*****\n"); 
    console.log("Check below for your random team!\n"); 
    console.log("           ↓↓↓↓↓↓↓↓↓↓");
    console.log(`\nPoint Guard   : ${team[0]}\nSmall Forward : ${team[1]}\nCenter        : ${team[2]}`)
};

//runs displayteam function which inputs the generate team function to get its return value
displayTeam(generateTeam(threePlayerTeam)); 
1 Like