i was doing merge sorted list on leetcode bc i wanna see if i could bc i never did leetcode and did this one but im confused bc to me how i solved it makes sense but it doesnt work
function merge(list1, list2) {
const newlist =[];
for(let i = 0; i < list1.length; i++){
for(let j =0; j <list2.length; j++){
if(list1[i] < list2[j]){
newlist.push(list1[i]);
}else if(list1[i] > list2[j]){
newlist.push(list2[j]);
}else if(list1[i] === list2[j]){
newlist.push(list1[i]);
newlist.push(list2[j])
}
}
}
return newlist;
};
console.log(merge([1,2,4],[3,4]))