面试题答案
一键面试// 创建包含一个字符串和一个数字的元组类型
type StringNumberTuple = [string, number];
// 定义函数,接受元组作为参数并拼接成新字符串返回
function concatenateTuple(tuple: StringNumberTuple): string {
return tuple[0] + tuple[1].toString();
}
// 测试函数
let myTuple: StringNumberTuple = ['abc', 123];
let result = concatenateTuple(myTuple);
console.log(result);