Why doesn't this code work

let nums1 = [1, 3];
let nums2 = [2];
var nums;
var findMedianSortedArrays = function(nums1, nums2) {
    var arr = nums1.concat(nums2);
    return arr;

So you’re defining a function, findMedianSortedArrays(), and you’re creating two local variables in those parameter names you’ve chosen. But you never actually call the function you’ve just created. add a line:

console.log(findMedianSortedArrays(nums1, nums2);

That will pass the global nums1 and nums2 arrays in as parameters to your function, which will then reference them.

See it run:

return stops execution of the function and nothing runs after it inside the function. Try placing console.log(arr); before return.

1 Like

while true, that still doesn’t address the fact that assigning a function to a variable isn’t actually executing that function.