var arrOne = [0, 9, 10, 11, 12, 20, 28, 32, 33, 47, 65, 69],
arrTwo = [8, 14, 15, 16, 17, 18, 19, 31, 35, 36, 37, 58, 68, 73];
function foo(e, f) {
var b = [],
d = [f[0]];
e.forEach(function(c,i) {
a = d.slice(-1)[0];
c > a && (arrTwo.some(function(b) {
return b > c && d.push(b)
}), c = e[i - 1], b.push(c))
});
b.push(e.slice(-1)[0]);
return {
one: b,
two: d
}
};
var res = foo(arrOne, arrTwo);
alert(res.one + '\n'+res.two)
|