Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Aug 17 09:33
    User @bjorno43 unbanned @linkin-park
  • 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
Saif Ur Rahman
@saifsmailbox98
@Shadilix you are not returning after the for loop and you can put the for loop inside an else.
Joseph
@revisualize
@Shadilix If you count down you could end up with a problem where you break below the loop.
@Shadilix You also don't have a return statement for your function.
@Shadilix You have one if the value of num is 0. But, you don't have one for anything else.
Ahmed Ramy
@Shadilix
opps yea i forgot the return
but when i used the counting "up" ... i ended up with an infinite loop
Stephen James
@sjames1958gm
@Shadilix And you are multiplying by num twice
@Shadilix Did you grow num and try to stop at num?
Ahmed Ramy
@Shadilix
@Shadilix Did you grow num and try to stop at num?
what ? XD
Saif Ur Rahman
@saifsmailbox98
@Shadilix you are also multiplying num with num in the first run
Stephen James
@sjames1958gm
@sjames1958gm i < num while also doing num *= i
kumquatfelafel
@kumquatfelafel
@Shadilix he means, did you have something like i <= num or whatever... which you had
Ahmed Ramy
@Shadilix
um shouldnt that code be like
num = 5
then
i = 5
then what happens in the loop is
543*2?
Saif Ur Rahman
@saifsmailbox98
5 * 5 * 4 * 3 * 2
kumquatfelafel
@kumquatfelafel
@Shadilix num is already 5, so this happens ^^^
Ahmed Ramy
@Shadilix
function factorialize(num) {
  if (num === 0)
    {
      return 1;
    }
  for (var i = num -1 ; i >=2 ; i--)
    {
      num *= i;
    }
  return num;
}

factorialize(1);
that worked ! :D
Stephen James
@sjames1958gm
@Shadilix :+1:
Saif Ur Rahman
@saifsmailbox98
:+1:
Ahmed Ramy
@Shadilix
thanks !!!!
@saifsmailbox98 @saifsmailbox98 @kumquatfelafel
CamperBot
@camperbot
shadilix sends brownie points to @saifsmailbox98 and @kumquatfelafel :sparkles: :thumbsup: :sparkles:
:cookie: 375 | @kumquatfelafel |http://www.freecodecamp.com/kumquatfelafel
:cookie: 636 | @saifsmailbox98 |http://www.freecodecamp.com/saifsmailbox98
kumquatfelafel
@kumquatfelafel
@Shadilix what you can also do is create another variable to store the product. That way, you can go up or down with ease without modifying num.
Ahmed Ramy
@Shadilix
how so ?
@sjames1958gm thanks !
CamperBot
@camperbot
shadilix sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7935 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
kumquatfelafel
@kumquatfelafel
@Shadilix you'd just have something like...
function factorialize(num) {
  var factorial =1;
  for (var i = 2; i <= num ; i++)
  {
      factorial *= i;
  }
  return factorial;
}
Ahmed Ramy
@Shadilix
oh , i tried that but for some reason it didnt work ...
hold on i'll try it again before going for the next challenge
Roxroy
@roxroy
@kysnazz , you can round the number to 2 decimal places
console.log( ( 0.6*6).toFixed(2) ) // OutPut 3.60
CamperBot
@camperbot
:bulb: to format code use backticks! ``` more info
Ahmed Ramy
@Shadilix
@kumquatfelafel
function factorialize(num) {
  var factorial = 1;
  for (var i =2 ; i <= num ; i++)
    {
      factorial = num*i;
    }
  return factorial;
}
it doesnt work
Nick Cleary
@Hijerboa
'''
CamperBot
@camperbot
:bulb: to format code use backticks! ``` more info
Saif Ur Rahman
@saifsmailbox98
CamperBot
@camperbot
:bulb: to format code use backticks! ``` more info
Nick Cleary
@Hijerboa
can someone tell me why my code isn't working?
function palindrome(str) {
  str.toLowerCase();
  var workingString = str.replace(/[`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi, '');
  var splitup = workingString.split("");
  var reversed = splitup.reverse();
  var joined = reversed.join("");
  var newString = joined;
  if(newString === str){
    return true;
  } else {
    return false;
  }

}
It works for anything without special characters
kumquatfelafel
@kumquatfelafel
@Hijerboa I would avoid having something like that in your replace function. Take a closer look at what's available for regex https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
Nick Cleary
@Hijerboa
I tried something like .replace(/[^\w\s]/gi, '') which should replace all special characters will null I believe but that didn't work either
Coy Sanders
@coymeetsworld
\w includes whitespace
http://regexr.com/ can test out regex here
kumquatfelafel
@kumquatfelafel
@Hijerboa One thing I will say is that strings are immutable. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLowerCase
As a result, your toLowerCase actually does not change your original string, but returns a new string that you do nothing with.
Mois├ęs Man
@moigithub
\w includes _
soo that regex will KEEP _ @Hijerboa and spaces
Nick Cleary
@Hijerboa
@kumquatfelafel so I should make an new variable with the toLowerCase, like I did with the replace?