Reputation: 1155
I am struggling with a problem in TypeScript and I was wondering if someone can help me out. Can anyone help? I am currently learning TypeScript and using an if/else statement or a switch statement was what initially came to mind first.
Problem: Complete the method that takes a boolean value and returns a "YES" if true and "NO" if false.
export const boolToWord = (bool: boolean): string => {
throw new Error("Not implemented!");
};
This is the first solution I came up with was using an if/else statement and that did not work.
export const boolToWord = (bool: boolean): string => {
if(true){
return "Yes"
} else if (false) {
return "No"
} else if {
return "Not Implemented"
}
};
boolToWord(True);
I also tried using a switch statement, but that did not work.
export const boolToWord = (bool: boolean): string => {
switch(boolean){
case: true;
console.log("YES");
break;
case: false;
console.log("NO");
break;
case: error;
console.log("Not Implemented")
break;
}
};
boolToWord(True);
Upvotes: 0
Views: 1461