面试题答案
一键面试function combineTupleElements([num, str, bool, ...rest]: [number, string, boolean, ...any[]]): string {
let result = num.toString() + str + bool.toString();
rest.forEach(element => {
result += element.toString();
});
return result;
}
示例调用:
let tuple1: [number, string, boolean, string] = [1, 'hello', true, 'world'];
let combined = combineTupleElements(tuple1);
console.log(combined);