Skip to content

Instantly share code, notes, and snippets.

@chikoski
Created October 23, 2014 01:27
Show Gist options
  • Select an option

  • Save chikoski/c1664199cf84620212fb to your computer and use it in GitHub Desktop.

Select an option

Save chikoski/c1664199cf84620212fb to your computer and use it in GitHub Desktop.
var createSpacer = function(n, numberOfRows){
var spacer = "";
var i = 0;
var diff = numberOfRows - n;
while(i < diff){
spacer = spacer + " ";
i = i + 1;
}
return spacer;
};
var repeatSFC = function(n){
var outputValue = "";
var i = 0;
while(i < n){
outputValue = outputValue + "SFC ";
i = i + 1;
}
return outputValue;
};
var nSFC = function(n, numberOfRows){
var outputValue =
createSpacer(n, numberOfRows) +
repeatSFC(n);
console.log(outputValue);
};
var sfcPyramid = function(numberOfRows){
var i = 1;
while(i <= numberOfRows){
nSFC(i, numberOfRows);
i = i + 1;
}
};
sfcPyramid(5);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment