I need help

I need help how to make table

/**We want to create, retrieve, and add information about your favorite sports team. Basketball, soccer, tennis,water polo, you pick it. It’s your job to create data using the JavaScript data structures at your disposal: arrays and objects. */
const favoriteSportsTeam = (name, number_of_games, average_score, win, loss) => {
    return {
        name,
        number_of_games,
        average_score,
        win,
        loss,
        set teamName(teamName) {
            if (typeof teamName === 'string') {
                this.name = teamName;
            } else { console.log("wrong entry"); }
        },
        set teamGames(number_of_games) {
            if (typeof number_of_games === 'number') {
                this.number_of_games = number_of_games;
            } else { console.log("wrong entry"); }
        },
        set teamAverageScore(average_score) {
            if (typeof average_score === 'number') {
                this.average_score = average_score;
            } else { console.log("wrong entry"); }
        },
        set teamWin(win) {
            if (typeof win === 'number') {
                this.win = win;
            } else { console.log("wrong entry"); }
        },
        set teamLoss(loss) {
            if (typeof loss === 'number') {
                this.loss = loss;
            } else { console.log("wrong entry"); }
        },
        get teamStats() {
            if (this.name &&
                this.number_of_games &&
                this.average_score &&
                this.win &&
                this.loss) {
                console.table(` Team: ${this.name}\n Games: ${this.          number_of_games}
                Average Scores: ${this.average_score}
                Wins: ${this.win}
                loss: ${this.loss}`);
            }
        }
    }

};
const basketball = favoriteSportsTeam("San Antonio Spurs", 82, 109, 66, 16);
basketball.teamStats;

I want this code in table form but it seems the console.table method doesn’t work please help anybody?

I did console.table(basketball); and it worked okay.

/**We want to create, retrieve, and add information about your favorite sports team. Basketball, soccer, tennis,water polo, you pick it. It’s your job to create data using the JavaScript data structures at your disposal: arrays and objects. */ const favoriteSportsTeam = (name, number_of_games, average_score, win, loss) => { return { name, number_of_games, average_score, win, loss, set teamName(teamName) { if (typeof teamName === 'string') { this.name = teamName; } else { console.log("wrong entry"); } }, set teamGames(number_of_games) { if (typeof number_of_games === 'number') { this.number_of_games = number_of_games; } else { console.log("wrong entry"); } }, set teamAverageScore(average_score) { if (typeof average_score === 'number') { this.average_score = average_score; } else { console.log("wrong entry"); } }, set teamWin(win) { if (typeof win === 'number') { this.win = win; } else { console.log("wrong entry"); } }, set teamLoss(loss) { if (typeof loss === 'number') { this.loss = loss; } else { console.log("wrong entry"); } }, get teamStats() { if (this.name && this.number_of_games && this.average_score && this.win && this.loss) { console.log(` Team: ${this.name} Games: ${this.number_of_games} Average Scores: ${this.average_score} Wins: ${this.win} loss: ${this.loss}`); } } } }; const basketball = favoriteSportsTeam("San Antonio Spurs", 82, 109, 66, 16); basketball.teamStats; console.log("\n"); console.table(basketball);

I changed the console.table in the getter to console.log

1 Like

thank you so much. much better to look at in table form. hehehe

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.