## Where communities thrive

• Join over 1.5M+ people
• Join over 100K+ communities
• Free without limits
##### Activity
• Aug 17 09:33
• Jun 20 21:19
@bjorno43 banned @shenerd140
• May 10 09:13
@bjorno43 banned @zhaokunhaoa
• Apr 25 17:12
@mstellaluna banned @cmal
• Apr 01 18:11
thecodingaviator labeled #31179
• Apr 01 18:11
thecodingaviator labeled #31179
• Apr 01 18:09
thecodingaviator commented #31179
• Apr 01 18:09
thecodingaviator labeled #31182
• Apr 01 18:09
thecodingaviator labeled #31182
• Apr 01 18:07
thecodingaviator commented #31182
• Apr 01 18:07
thecodingaviator labeled #31190
• Apr 01 18:07
thecodingaviator labeled #31190
• Apr 01 18:07
thecodingaviator commented #31190
• Apr 01 18:05
thecodingaviator commented #31157
• Apr 01 18:04

thecodingaviator on master

remove A (#31157) (compare)

• Apr 01 18:04
thecodingaviator closed #31157
• Apr 01 18:04
thecodingaviator closed #33788
• Apr 01 18:04
thecodingaviator commented #33788
• Apr 01 18:02
thecodingaviator closed #31059
• Apr 01 18:02
thecodingaviator commented #31059
Nick Cleary
@Hijerboa
@camperbot np mate
Hey can anyone explain to me how this has an infinite loop?
function sumPrimes(num) {
var isPrime = true;
var counter = 1;
var sum = 0;
while(counter <= num){
if(counter >= 3){
for(i=3; i<=(counter/2); i+2){
if(Number.isInteger((counter/i))){
isPrime = false;
i = ((counter/2)+1);
} else {
isPrime = true;
}
}
} else if(counter >= 2){
isPrime = false;
}
if(isPrime){
sum += counter;
counter++;
}else{
counter++;
}
}
return sum;
}
FCC says there's an infinite loop at the if(counter >= 3) part
Coy Sanders
@coymeetsworld
your for loop has a bug
@Hijerboa
Nick Cleary
@Hijerboa
@coymeetsworld does it have to do with the statement i<=(counter/2) ?
Coy Sanders
@coymeetsworld
no
the logic looks complicated though, i don't like that you are modifying i in other places, it opens yourself to bugs
Nick Cleary
@Hijerboa
ohhhhh its the i+2
it should be i+=2... corrrect?
Coy Sanders
@coymeetsworld
yes
but the other times you may change i could cause issues too
there may be an inf loop there too
i would rethink this
Nick Cleary
@Hijerboa
ok... Legitimate question: how else would I break out of the for loop?
or should i not use a for loop at all?
because thats the only way i can think of to test for primes
Manish Giri
@Manish-Giri
@Hijerboa return inside a for loop would terminate it..
Gersho
@Gersho
wouldn't that stop the function too ?
Nick Cleary
@Hijerboa
@Manish-Giri as @Gersho it would stop the function... and im trying to add all primes for one of the challenge
Coy Sanders
@coymeetsworld
use break to break out of the loop
Manish Giri
@Manish-Giri
then use break
besides, I did say "terminate", didn't I?
Gersho
@Gersho
you did, but it terminates more than intended :P
Nick Cleary
@Hijerboa
@coymeetsworld @Manish-Giri I honeslty had no idea break existed....
Manish Giri
@Manish-Giri
terminate was meant as terminate the function.
Gersho
@Gersho
break and continue are both keyword usable within a loop @Hijerboa
Nick Cleary
@Hijerboa
@Gersho @Manish-Giri @coymeetsworld TIL... thanks guys
CamperBot
@camperbot
hijerboa sends brownie points to @gersho and @manish-giri and @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 3000 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
:star2: 6512 | @manish-giri |http://www.freecodecamp.com/manish-giri
Gersho
@Gersho
@coymeetsworld 3k, congratulation
Manish Giri
@Manish-Giri
woot woot, congrats @coymeetsworld
Coy Sanders
@coymeetsworld
:ok_hand: only took like 2 months since 2990 lol
Manish Giri
@Manish-Giri
lol
Coy Sanders
@coymeetsworld
then again i was on vacation pretty much all last month
hey guys
Gersho
@Gersho
Ronique Ricketts
@RoniqueRicketts
Sup
got a quick issue i'm trying to fix
nvm, got it
haha
Gersho
@Gersho
CodeAcademy's React lessons are nice, but i'm getting tired of copy pasting document.getElementById('app')
luccifer00
@luccifer00
hie there! i would like to créate a function for créate an ordered list based on letters, A-Z, so the next after Z should be AA, AB, .... and After ZZ, should be AAA, AAB, and so on....
for(var i=0;i<input;i++){
var letter=String.fromCharCode(i+65);
if(letter> 91){

}
}
i have this start, but i dont know how to realice at all...
Bryan Reese
@breese8009
so i got 2 functions, one is rendering, the other at this point I just want to get the exact data-id everytime i click on a .list-group-item but i only get the first one right then it will just keep logging that one over an over...
function renderListStyle(style) {

let styleHtml=
<a href="#" class="list-group-item list-group-item-action" data-id="${style._id}">${style.type}</a>

$('.list-group-style').prepend(styleHtml); } function activeStyles(e) { let styleId =$(this).find('a').attr('data-id');
console.log(styleId)

}