面试题答案
一键面试function combineValues(a: number, b: number): number;
function combineValues(a: string, b: string): string;
function combineValues(a: number | string, b: number | string): number | string {
if (typeof a === 'number' && typeof b === 'number') {
return a + b;
} else if (typeof a ==='string' && typeof b ==='string') {
return a + b;
} else {
throw new Error('Invalid argument types');
}
}