## Where communities thrive

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

thecodingaviator on master

remove A (#31157) (compare)

• Apr 01 2019 18:04
thecodingaviator closed #31157
• Apr 01 2019 18:04
thecodingaviator closed #33788
• Apr 01 2019 18:04
thecodingaviator commented #33788
• Apr 01 2019 18:02
thecodingaviator closed #31059
Joseph
@revisualize
Hey hey.
Ahmed Ramy
thanks :D
i am trying something , will show u in a bit
kumquatfelafel
@kumquatfelafel
hi
Ahmed Ramy
function factorialize(num) {
if (num === 0)
{
return 1;
}
for (var i = num ; i >=2 ; i--)
{
num *= i;
}
}
ohh that also didnt work
kumquatfelafel
@kumquatfelafel
2.what happens when num = 1?
Joseph
@revisualize
@Shadilix You know.. It's actually better to count up than to count down.
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 have one if the value of num is 0. But, you don't have one for anything else.
Ahmed Ramy
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 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
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
Ahmed Ramy
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
Saif Ur Rahman
@saifsmailbox98
:+1:
Ahmed Ramy
thanks !!!!
@saifsmailbox98 @saifsmailbox98 @kumquatfelafel
CamperBot
@camperbot
shadilix sends brownie points to @saifsmailbox98 and @kumquatfelafel :sparkles: :thumbsup: :sparkles:
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
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
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
@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