Back in Action!(FCC challenge Factorialize a Number)

Sorry for the hiatus. I’ve been away for so long. It’s been 10 months since I’ve coded and completed any FCC challenges. But I must say since I began to review the old material and go through old bonfire challenges I can tell you the knowledge and passion haven’t gone anywhere. Today I began going over the basic algorithm scripting challenges and I completed the “Reverse a string” challenge easy enough. Then the next challenge began which indeed was the “Factorialize a Number” bonfire. When I first began my coding journey May 24th 2016 I remember arriving at this challenge and have so many problems with…….. everything. But today I completely smoked this challenge.

To begin, I setup a simple if statement to satisfy the criteria that states a 1 must return if your number is 0.And that simply looks like this

function factorialize(num) {
if(num === 0){
return 1;

Next I made a variable that contains an empty array and setup a for loop that would deposit the number to be multiplied into that array.


var myArray = [];
for (var i = 1; i <= num; i++){

Lastly all that was needed to be done was to use the reduce method in order to turn that array into my solution. 

var newFact = myArray.reduce(function(a,b){
return a * b;

return newFact;



I hope that helps someone if they’re stuck and if at you need any motivation to keep going. Be Good and Happy Coding!



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s