Re: Learning arraysã > By: Mortifis to All on Wed Jul 17 2019 11:09:38ãã > Mo> var has_dup = false;ãã > This is not an array, so later when you do this:ãã > Mo> has_dup[i] = true; ãã > you're setting property [i] on a boolean to 'true'. Interestingly thisã > doesn't generate anã > error, but it also doesn't store that property/value.ãã > Instead of this:ãã > var has_dup = false;ãã > you probably want this:ãã > var has_dup = [];ãã > Note that you're also declaring 'dups' twice:ãã > Mo> var dups=0;ã > Mo> var dups;ãã > So by the time your script gets down to business, 'dups' is undefined andã > your 'dups++'ã > won't work. (Just remove that 'var dups;' line.)ãã > Your nested for loop could be sped up a little bit:ãã > for (var n = i + 1; n <= lastuser; n++) {ãã > You've already dupe-checked all users up to i, and you want to start withã > users beginning atã > i + 1. This would also remove the need for the 'if(u.number == d.number)ã > continue;' check.ããyes that sped things up and also forced a deletion of dups = dups/2; :-)ã ã ã > I could go on with some other suggestions, but I'll stop here for now.ããI am open to suggestions but I think I have a handle on the has_dup Array,ãthank you :)ããããMy teachers always said "You can't make a living looking out a window!", theyãwere wrong, I drive truck :-Pãã---ã þ Synchronet þ AlleyCat! BBS - http://alleycat.synchro.net:81ã
Sysop: | Karloch |
---|---|
Location: | Madrid, Spain |
Users: | 54 |
Nodes: | 8 (0 / 8) |
Uptime: | 128:52:40 |
Calls: | 700 |
Files: | 17,895 |
D/L today: |
128 files (60,769K bytes) |
Messages: | 66,010 |