Sorted Union... Help

Sorted Union... Help
0

#1

I know the code I wrote is wrong, I just tried what I could think of.
Can you offer some examples of what I should be doing instead?
If you have a code that does what I aiming for, I do not mind if you share.
Thank you,
SDC

function uniteUnique(arr) {
 var emptyArr = []; //empty array
  emptyArr = emptyArr.concat(arr)//empty arr = arr.concat
  for(var i = 0; i<arr.length; i++){
    if(arr[i] === true){
     emptyArr = arr[i].delete(arr[i]);
    }
    }//if arr[i] does exit, delete
  //return "empty array"
  return emptyArr;
}

#2

Have you tried writing an algorithm in plain language first before trying to write code? Make sure you can document the logical steps you would need to create a sorted union of the arrays.

If that is too much, try writing out the steps for creating a sorted union of just two arrays. Then build upon the logic to apply it to multiple arrays.

You state you know your code is not right. We are not going to just give you the solution. You are going to have to show you have tried first. Post your algorithm and we can make sure you are on the right path before writing any code.


#3

Thank you so much. I will begin to think about writing code differently. I will definitely try to write out the code in plain English. Seriously, thanks. I think that process will help me understand what I’m doing a lot better. I am so new to this, so teaching me how to process what I am doing is SUCH a help!
This is actually my solo attempt at it (oh no!). I will post my plain English code along with my attempt to translate it if it doesn’t work. Will you tell me what I am doing wrong when I do that? I would like your explanation of it. Please?


#4

My English version! I will try to translate and would appreciate ALL help!

/*when given multiple arr, they will need to be numbered to distiguish them.
if the first arr has number x, x needs to be deleted from the next arr.
the first and the following arr needs to be connected.
voila! return the connected arr.
*/

#5

Break these two steps you have written into smaller steps.

The above is two smaller steps.

  1. How do find the number x is the first array?

  2. Describe the process of how you would find another x in the next array and delete it.

What do you mean they need to be connected? Describe how you would connect them in smaller steps.