-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
26 lines (22 loc) · 706 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
let costOfItemsAtTraderJoes = [1, 2, 6, 7, 8]
let costOfItemsAtWholeFoods = [3, 4, 5, 9, 10]
let firstHalf = [1, 2, 6, 7, 8]
let secondHalf = [3, 4, 5, 9, 10]
function findMin(firstHalf, secondHalf){
let minfirstHalf = firstHalf[0]
let minsecondHalf = secondHalf[0]
function findMinAndRemoveSorted = (1,2,3,4);
if(minfirstHalf < minsecondHalf){
return minfirstHalf
} else {
return minsecondHalf
}
}
function merge(firstHalf, secondHalf){
let sorted = []
while(firstHalf.length != 0 && secondHalf.length != 0){
let currentMin = findMinAndRemove(firstHalf, secondHalf)
sorted.push(currentMin)
}
return sorted.concat(firstHalf).concat(secondHalf)
}