Categories
Mastering Development

How to return function value only by calling constructor [closed]

So my javascript class looks like this:

class Teams {
    get myteams() {
        return [
            'Man utd',
            'Barcelona'
        ]
    }

    constructor(){
        return this
    }
}

console.log(Array.from(new Teams()).join(','));

Without chanving the constructor, how can I print the content of the array in the function "myteams"?

Note that the constructor has to remain untouched. Also, I cannot add anything in the console.log. The changes need to be made inside the class.

Leave a Reply

Your email address will not be published. Required fields are marked *