13th
Jun 2018
Ryan Williams
@Ryanwfile
Jun 13 2018 02:05 UTC
I am working on the merge sort algorithm and seem to have an infinite loop which I can pinpoint but can't figure out why it's infinite, the loop is caused by the b = mergeSort(b) in the first function, any help is greatly appreciated thank you
function mergeSort(arr) {
if (arr.length === 1){
return arr;
}
var mid = Math.round(arr.length/2);//find the midpoint of array
var a = arr.splice(0,mid);//split array into 2 halves, left half being greater if odd number
var b = arr;
a = mergeSort(a);
b = mergeSort(b);//*************************this is causing the infinite loop
return merge(a,b);
}

function merge(left,right){
var c = [];
while(left.length >= 1 && right.length >= 1){//while both halves have elements
if(left[0] > right[0]){//goes through each array comparing each 0 index
c.push(right[0]);
right.shift();
}
if(right[0] > left[0]){
c.push(left[0]);
left.shift();
}
}
while(left.length >= 1){
c.push(left[0]);
left.shift();
}
while(right.length >= 1){
c.push(right[0]);
right.shift();
}
return c;
}
console.log(mergeSort([1,7,3,4,16,2]));
Bjorn van de Peut
@bjorno43
Jun 13 2018 02:19 UTC
@Ryanwfile Because b is the full array you're passing on as the parameter. Basicly b = mergeSort(b); === mergeSort([1,7,3,4,16,2]). So it keeps on calling that over and over again.
First you're setting var b = arr; where arr represents the value of the parameter: mergeSort(arr). So nothing is changed to b on each loop. It's just the same value over and over again, never returning anything because it keeps on calling itself before something is returned. Hence infinite loop
Ryan Williams
@Ryanwfile
Jun 13 2018 02:33 UTC
@bjorno43 Thank you very much, that makes sense. Why when I console b though it shows [4, 3, 2] as hoped?
Bjorn van de Peut
@bjorno43
Jun 13 2018 02:37 UTC
@Ryanwfile Not entirely sure. I'm gonna run some tests, I'll let you know
Ryan Williams
@Ryanwfile
Jun 13 2018 02:37 UTC
@bjorno43 Sounds great, thanks again
the codepen is https://codepen.io/Ryanwfile/pen/pLXMGP if it helps
Bjorn van de Peut
@bjorno43
Jun 13 2018 02:47 UTC
@Ryanwfile Actually, it's not returning an infinte loop. I forgot that splice actually modifies the original array. Tested that code locally in my browser and it works perfectly fine. So something else must be going on
Ryan Williams
@Ryanwfile
Jun 13 2018 02:50 UTC
that's great to hear, maybe I screwed up somewhere else then, thanks so much
Joshua Arnett
@josha5
Jun 13 2018 02:52 UTC
Hey all, really stuck and was wondering if anyone could help debug dynamically creating markers using the google maps api in react?
Ryan Williams
@Ryanwfile
Jun 13 2018 02:53 UTC
@bjorno43 It seems to work fine in the chrome console but doesn't work in the FCC or codepen console at all
Bjorn van de Peut
@bjorno43
Jun 13 2018 02:55 UTC
@Ryanwfile Works perfectly fine in codepen for me? https://codepen.io/bjorno43/pen/JZJjYg?editors=1111
Ryan Williams
@Ryanwfile
Jun 13 2018 03:02 UTC
@bjorno43 Interesting, I just copy and pasted it repeatedly in codepen and eventually it started to work in my pen as well, no idea what was happening
@bjorno43 Thanks for the help
Bjorn van de Peut
@bjorno43
Jun 13 2018 03:03 UTC
@Ryanwfile Perhaps just write your own codepen? It's pretty easy to make, haha :P
Ryan Williams
@Ryanwfile
Jun 13 2018 03:17 UTC
Still doesn't work in the FCC test but it works fine everywhere else, no idea what's wrong with it
@developer4eto
Jun 13 2018 05:14 UTC
@Ryanwfile are you sure you didn't change something in your codepen, because it work fine on my codepen?
Gunhoo Yoon
@gunhoo93
Jun 13 2018 08:25 UTC
@Ryanwfile You never check for equality. If a test input contains duplicated elements, merge() loops indefinitely
Jason Luboff
@JLuboff
Jun 13 2018 15:07 UTC
Morning :wave:
Diego Mayer
@Chrono79
Jun 13 2018 15:17 UTC
:wave:
Jason Luboff
@JLuboff
Jun 13 2018 15:17 UTC
Master Codewarrior!
Diego Mayer
@Chrono79
Jun 13 2018 15:21 UTC

Master Codewarrior!

I wish, I'm only a codegrasshopper with tenacity ;)

Jack Shijin
@Jackshijin
Jun 13 2018 15:49 UTC
still don't know how to cross the easy 160
Jason Luboff
@JLuboff
Jun 13 2018 15:50 UTC
@Jackshijin Challenges have names, not numbers
whats the challenge and whats the problem you're having?
Jack Shijin
@Jackshijin
Jun 13 2018 15:50 UTC
Word Blanks
Jason Luboff
@JLuboff
Jun 13 2018 15:51 UTC
Ok, and what is your current code?
Jack Shijin
@Jackshijin
Jun 13 2018 15:51 UTC
I can't understand it's current requst
Jason Luboff
@JLuboff
Jun 13 2018 15:53 UTC
Ok, you need to use string concatenation using + to create a string using the provided parameters (myNoun, myAdjective, etc)
and assign that to result
Jack Shijin
@Jackshijin
Jun 13 2018 15:54 UTC
just like this ?
but it doesn't work
Jason Luboff
@JLuboff
Jun 13 2018 15:55 UTC
You need to have spaces in between. Currently you would have DogRun... Or whatever the words are. There's no spaces
Jack Shijin
@Jackshijin
Jun 13 2018 15:56 UTC
wordBlanks("dog ","big ","ran ","quickly");
Jason Luboff
@JLuboff
Jun 13 2018 15:56 UTC
You should not be modifying the function call, that is bad.
Jack Shijin
@Jackshijin
Jun 13 2018 15:56 UTC
really?
Jason Luboff
@JLuboff
Jun 13 2018 15:56 UTC
Yes.
Jack Shijin
@Jackshijin
Jun 13 2018 16:00 UTC
@JLuboff done , thanks
Jason Luboff
@JLuboff
Jun 13 2018 16:00 UTC
:+1:
Jack Shijin
@Jackshijin
Jun 13 2018 16:00 UTC
I think it may be a bug at first
So embarrassed
Jason Luboff
@JLuboff
Jun 13 2018 16:01 UTC
It takes time and effort, which it looks like you're putting in
Don't expect to be an expert after a short time
Jack Shijin
@Jackshijin
Jun 13 2018 16:03 UTC
Get it.
Jun 13 2018 17:14 UTC
God the madness that is legacy code..... why uses var self = this when you have es7 support! :_(
Kaz Baig
@kbaig
Jun 13 2018 17:15 UTC
@bradtaniguchi wait did this used to be self
Jun 13 2018 17:15 UTC
No, its a convention used back in the day before arrow functions,
I say legacy code, for code thats 10 months old >.>
Kaz Baig
@kbaig
Jun 13 2018 17:16 UTC
oh I see what you mean now
to be able to refer to outer this
Jun 13 2018 17:17 UTC
yea, but if the guy used arrow functions, no need, which he didn't use :/
Kaz Baig
@kbaig
Jun 13 2018 17:17 UTC
Yeah :(
Kudzu
@czhower
Jun 13 2018 17:17 UTC
@kbaig Self is from Delphi... sounds like a Delphi programmer was there.
Kaz Baig
@kbaig
Jun 13 2018 17:18 UTC
I thought it was also in python
Jun 13 2018 17:18 UTC
Hes more like an "enterprise java developer" that was writing javascript, in a typescript environment
lots of "I don't care about the reprocussions, I need to make the deadline" code.
Kudzu
@czhower
Jun 13 2018 17:19 UTC
yeah, python as well. Didnt know that.
Jun 13 2018 17:19 UTC
Yea, python has self instead of this, but same idea, its just more damn clear
Kudzu
@czhower
Jun 13 2018 17:21 UTC
VB used "Me" :)
Jun 13 2018 17:21 UTC
now sombody gotta use i and everyone important is included :P
Kudzu
@czhower
Jun 13 2018 17:27 UTC
because of JS wandering this, sometimes I store it as xThat... so I have xThis and xThat....
Jason Luboff
@JLuboff
Jun 13 2018 18:21 UTC
Sure would be nice if people responded to emails if they want their app finished any time soon..
Jun 13 2018 18:22 UTC
I agree hehe
Jason Luboff
@JLuboff
Jun 13 2018 18:23 UTC
I love how I send the email, took 5 days to get a response (sent it Friday, only got one actual response today still need another person to respond). I respond back to that email and asked an additional question and the additional question was ignored..
Kaz Baig
@kbaig
Jun 13 2018 18:53 UTC
@JLuboff People usually stop responding as soon as things you want to do something slightly inconvenient for them. That's how it goes at my company :/
Jason Luboff
@JLuboff
Jun 13 2018 18:53 UTC
Its just inconvenient for them to respond it seems.. I'm building this for them afterall hah
Jason Luboff
@JLuboff
Jun 13 2018 20:13 UTC
Oh hey, they responded! Sweet
Jun 13 2018 20:16 UTC
just in time haha
Jason Luboff
@JLuboff
Jun 13 2018 20:21 UTC
Yup! Can get shit done now
anthonygallina1
@anthonygallina1
Jun 13 2018 20:34 UTC
:smile:
@JLuboff :snail: mail
Good thing it doesnt cost a stamp. Seems faster some times though IMO.
Jason Luboff
@JLuboff
Jun 13 2018 20:37 UTC
Haha no joke there
anthonygallina1
@anthonygallina1
Jun 13 2018 20:37 UTC
:smile:
Ryan Williams
@Ryanwfile
Jun 13 2018 20:57 UTC
@developer4eto @gunhoo93 Thank you, I got it working after taking a break
Jason Luboff
@JLuboff
Jun 13 2018 21:39 UTC
@cmccormack Since last time you made me feel bad about not using SSH...I'm using SSH to get this raspberry pi setup
Jun 13 2018 21:44 UTC
:+1: :+1: :+1:
my little baby is right next to me always available to be sshed into :D
Bjorn van de Peut
@bjorno43
Jun 13 2018 21:47 UTC
A monitor or keyboard is a luxury my server can't afford :trollface:
Jason Luboff
@JLuboff
Jun 13 2018 21:48 UTC
I'm just lazy haha
Christopher McCormack
@cmccormack
Jun 13 2018 21:56 UTC
Jason Luboff
@JLuboff
Jun 13 2018 21:57 UTC
I used to be all about that life..than...I was all like "The gui makes things easy..."
Christopher McCormack
@cmccormack
Jun 13 2018 21:57 UTC
Not if you're too lazy to move between keyboard and mouse :)
Jason Luboff
@JLuboff
Jun 13 2018 21:57 UTC
VNC/RDP/Dameware homie!
Christopher McCormack
@cmccormack
Jun 13 2018 21:58 UTC
I guess it's moot as I spend half the time in google looking up how to do something, maybe I should use that CLI versino of google
Jun 13 2018 21:58 UTC
My wrist hurts to much so less mouse is always good
Jason Luboff
@JLuboff
Jun 13 2018 21:59 UTC
There's a CLI version of google? oh no.. lol
Christopher McCormack
@cmccormack
Jun 13 2018 21:59 UTC
yup
CLI version of Reddit too
also CLI Star Wars telnet towel.blinkenlights.nl
Jun 13 2018 22:00 UTC
theres a cli browser too :D
Christopher McCormack
@cmccormack
Jun 13 2018 22:01 UTC
So hard to use - Lynx you mean right?
Jun 13 2018 22:02 UTC
Yea I think that was it, I only like to say its possible, forget about usability haha
Christopher McCormack
@cmccormack
Jun 13 2018 22:04 UTC
I think it would be cool if people made versions of sites specifically for that browser
Jun 13 2018 22:06 UTC
I think there was one other one that was better, had some GUI capabilities where it can show pictures. Wouldn'
work thru SSH (I would think haha) but a lot more usuable
Jason Luboff
@JLuboff
Jun 13 2018 22:07 UTC
@cmccormack Is that the one that plays star wars?
like.. real time
Christopher McCormack
@cmccormack
Jun 13 2018 22:08 UTC
yeah
I can't do it from the office but I think it still works
Jason Luboff
@JLuboff
Jun 13 2018 22:09 UTC
Hah, I started it once than got bored
Oh, actually went to the office today eh?
Christopher McCormack
@cmccormack
Jun 13 2018 22:13 UTC
Yeah came down for lunch with some colleagues and our VP, and there is a React meetup in Tempe that my work is sponsoring so going to that as well
Jason Luboff
@JLuboff
Jun 13 2018 22:14 UTC
Neat
Christopher McCormack
@cmccormack
Jun 13 2018 22:14 UTC
Yeah pretty cool. Sucks though that we went for pizza for lunch and the React meetups also serve pizza :/
too much pizza
And those meetups STINK of pizza the whole time
Jason Luboff
@JLuboff
Jun 13 2018 22:14 UTC
Ugh
Christopher McCormack
@cmccormack
Jun 13 2018 22:18 UTC
Yeah it's pretty gross
Jason Luboff
@JLuboff
Jun 13 2018 22:19 UTC
but...is it atleast good pizza..?
Christopher McCormack
@cmccormack
Jun 13 2018 22:20 UTC
I dunno I never eat it
Jason Luboff
@JLuboff
Jun 13 2018 22:20 UTC
Also... I hate IE
Christopher McCormack
@cmccormack
Jun 13 2018 22:20 UTC
Does it also stink like PIzza?
Jason Luboff
@JLuboff
Jun 13 2018 22:21 UTC
Yes. Yes it does
anthonygallina1
@anthonygallina1
Jun 13 2018 22:21 UTC
:wave:
Any one hear of In and out hamburgers?
Jason Luboff
@JLuboff
Jun 13 2018 22:22 UTC
In n Out is the best burger ever, yes
(for Fast food I should specify)
Its really the only fast food burger I eat (besides The Habit which is more inbetween fast food/sit down)
anthonygallina1
@anthonygallina1
Jun 13 2018 22:23 UTC
I had the ssame experience some time it smelled great Then other times bleh
Yes I agree @JLuboff
Jason Luboff
@JLuboff
Jun 13 2018 22:25 UTC
Apparently IE is real strict about ;...
anthonygallina1
@anthonygallina1
Jun 13 2018 22:26 UTC
HAd some fun flex time with that about a year ago wished I would have tested IE first afterwards
@JLuboff Rumor is some big companys are distancing them selves from IE
Jason Luboff
@JLuboff
Jun 13 2018 22:28 UTC
As they should
anthonygallina1
@anthonygallina1
Jun 13 2018 22:29 UTC
@JLuboff agree has been many headaches here
Jason Luboff
@JLuboff
Jun 13 2018 22:30 UTC
Unfortunately we're still have about 50-60% of the company running Windows 7, and while all computers have atleast Chrome if not FF as well, most users end up using IE so I still need to have this app for IE
Christopher McCormack
@cmccormack
Jun 13 2018 22:32 UTC
Jason Luboff
@JLuboff
Jun 13 2018 22:34 UTC
mehhh....I guess I could...but...
anthonygallina1
@anthonygallina1
Jun 13 2018 22:34 UTC
Or fallbacks
Or maybe if can be done gulp-autoprefixer": "^5.0.0 then take it out for production.
Christopher McCormack
@cmccormack
Jun 13 2018 22:38 UTC
dont think that polyfill would work for template literals though
would need transpiler - maybe run the whole thing through babel with presets
anthonygallina1
@anthonygallina1
Jun 13 2018 22:39 UTC
Oh i was talking about a node env for building
Jason Luboff
@JLuboff
Jun 13 2018 22:39 UTC
Well thats the only thing I'd really need them for.. I've already written everything else client side in ES5
Christopher McCormack
@cmccormack
Jun 13 2018 22:39 UTC
No Promises?
Jason Luboff
@JLuboff
Jun 13 2018 22:39 UTC
Not on the client side, no
richRocksCodeBlocks
@richRocksCodeBlocks
Jun 13 2018 23:03 UTC
@JLuboff Vocab for the day, the term for in-between (fast food & sit down) is fast casual. I'm a commercial real estate broker by day. FCC learner in-between showings.
Jason Luboff
@JLuboff
Jun 13 2018 23:04 UTC
@richRocksCodeBlocks Haha, thanks. I know I've heard that term before but never use it. I'll try to add it to my vocab though
richRocksCodeBlocks
@richRocksCodeBlocks
Jun 13 2018 23:05 UTC