I have a TypeScript class with a method that takes three arguments.
class MyClass {
public static carStatus(name : string , color : string , isReady : boolean){
let result = isReady ? 'is ready' : 'is not ready';
return `${color} ${name} ${result}.`;
}
}
let carStatus = MyClass.carStatus('pride' , 'white' , true);
console.log(carStatus);
I am looking to modify the way the third argument (isReady)
is passed into the method by moving it outside of the brackets.
class MyClass {
public static isReady : boolean;
public static carStatus(name : string , color : string){
let result = this.isReady ? 'is ready' : 'is not ready';
return `${color} ${name} ${result}.`;
}
}
MyClass.isReady = false;
let carStatus = MyClass.carStatus('pride' , 'white');
console.log(carStatus);
Are there any other methods to achieve the same outcome?