I posted about this before trying to use a regular expression, but this time is a bit different.
So I have this list of 500 phone numbers. Here is a little sample of them:
{
8664665844
8885444636
8664604776
8776434327
8887441938
8882642882
8888097429
8668943258
8777711234
8669894327
}
It looks a bit different, this is on my mongoDB server, so its more like an array of objects with a unique uid... so for example:
[
{
_id: kasjf234lkj109euf9023u4n,
field1: 8669894327,
}
]
something like that right.
So basically, my webapp is using a csv file of numbers that you want to compare to your base numbers.
My first thought was using a for, while, for loop kind of thing but im not sure how well it'll work:
for(var i = 0; i < basenums.length; i++){
while ( i >= 0 ){
for(var j = 0; j < comparing.length; j++){
if comparing[j] == basenums.field1[i]{
push that number to a 'dupes' array
}else{
break or something?
}
}
}
}
...this logic is starting to hurt my head...
I know theres an 'includes()' method, but I havn't really used it and when I tried it in this case, It gave me everything as false, even tho the list I was using to compare is just a copy of my 'basenums' list on my server.
What would be the more 'correct' way of doing this?
I'm trying to compare an array with an array. Not a value in its specific array to its own array.
So, rather than marking this as a duplicate, maybe you should re-read:
I have 2 arrays of numbers: [1, 2, 3, 4, 5, 6] and [1, 2, 3, 4, 5, 6] How do I take array a index 0 and compare it to array b every index, then take index 1 of array a and compare to every index in array b, so on and so forth until i > arrayA.length.