These are chat archives for codefellows/sea-f1-TAs/Brian

30th
Sep 2014
jongmink
@jongmink
Sep 30 2014 19:03
Hi, Brian. I have a question about "setTimeout." I created a while loop to sort a deck of cards. When I included "setTimeout," it creates infinite loop. Do you have any suggestions? Here is my code below.
var sort = function() {
has_moved = true
while(has_moved) {
has_moved = false
for (i = 0; i < $('li').length; i++) {
var first_item = $('li').eq(i)
first_item.addClass('highlight');
$('li').eq(i+1).addClass('highlight');
if (parseInt(first_item.attr('id')) > parseInt($('li').eq(i+1).attr('id'))) {
$('li').eq(i+1).after(first_item);
has_moved = true
}
}
}
}
Brian Caldwell
@Caldwerl
Sep 30 2014 20:02
if you want it to repeat, you should use setInterval
if you want it to perform a function once after a set amount of time, you should use setTimeout
Here is a bit of detail on how to go about that
My suggestion if you want the while loop to move at a slowed down pace, replace the while loop with a setInterval
and remember to use clearInterval() when you reach a stopping point
jongmink
@jongmink
Sep 30 2014 21:36
Thank you. It looks like it's working......
Matthew Conquergood
@kristjin
Sep 30 2014 21:38
FYI Lindy is saying we either have to test out of the GitHub class or attend. Any idea how I test out?
Brian Caldwell
@Caldwerl
Sep 30 2014 21:39
I guess link to your github? Ask her for details
Brian Caldwell
@Caldwerl
Sep 30 2014 21:52
Id recommend the class honestly, there are a lot of concepts in there that we didnt really touch on like branching, merging, pull requests etc
Matthew Conquergood
@kristjin
Sep 30 2014 21:52
you mean for JS?
oh, you mean for github
ugh, it's 8 hours!
I don't wannaaaa.... :)
Brian Caldwell
@Caldwerl
Sep 30 2014 21:52
Thats what the DA is gonna be
Buckle up
Matthew Conquergood
@kristjin
Sep 30 2014 21:52
Yeah, I don't mind 8 hours a day for the DA
but these are always on a Saturday. boo
If I can just test out, I'll do t hat before the Python F2
Brian Caldwell
@Caldwerl
Sep 30 2014 21:53
Opportunity costs
Matthew Conquergood
@kristjin
Sep 30 2014 21:53
I did finally get a reply back from Linday who is going to take care of moving me over to the Python class.
If you know anyone who was interested in JS but missed it, I'm leaving it, so they could possibly get my spot.
Brian Caldwell
@Caldwerl
Sep 30 2014 21:53
maybe let the general class chat know
Matthew Conquergood
@kristjin
Sep 30 2014 21:53
nod