const a = [1, 3, 5];
const b = [2, 4, 6, 7];
 
const sortArrays = <T extends number[]>(a: T, b: T): T => {
let aIndex = 0;
let bIndex = 0;
 
const result = []
while (aIndex < a.length && bIndex < b.length) {
if (a[aIndex] < b[bIndex]) {
result.push[a[aIndex]]
aIndex++
} else {
result.push[b[bIndex]]
bIndex++
}
}
 
while (aIndex < a.length) {
result.push[a[aIndex]]
aIndex++
}
while (bIndex < b.length) {
result.push[b[bIndex]]
bIndex++
}
 
 
}
 
console.log(sortArrays(a, b));
Code will run automatically after changes.
Code runs in an isolated environment.