Skip to content

Instantly share code, notes, and snippets.

@yvan-sraka
Created October 26, 2016 13:55
Show Gist options
  • Save yvan-sraka/40bd5db6153531210bb652c5563ebf40 to your computer and use it in GitHub Desktop.
Save yvan-sraka/40bd5db6153531210bb652c5563ebf40 to your computer and use it in GitHub Desktop.
/*
* Triangle
*
* INPUT:
* - a number N
*
* OUPUT: (eg for N=5)
* #
* ##
* ###
* ####
* #####
*
*/
function Line(N) {
return "#".repeat(N);
}
function Triangle(N) {
for (var i = 1; i <= N; ++i) {
console.log(Line(i));
}
}
Triangle(5);
Triangle(3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment