Skip to content

Instantly share code, notes, and snippets.

@ashwinkumar2438
Last active September 8, 2020 05:45
Show Gist options
  • Save ashwinkumar2438/1b25d5dfe6d98d48cc81866dd059f854 to your computer and use it in GitHub Desktop.
Save ashwinkumar2438/1b25d5dfe6d98d48cc81866dd059f854 to your computer and use it in GitHub Desktop.
//Curried Function taking two parameters.
var repeatString=(string)=>(count)=>Array(count).fill(string).join("");
//Creating custom functions with currying.
var repeatStar=repeatString("*"); // (count)=>Array(count).fill("*").join("");
var repeatSpace=repeatString(" "); // (count)=>Array(count).fill(" ").join("");
for(let i=0;i<8;i++){
console.log(repeatSpace(8-i)+repeatStar(2*i+1));
}
/*
*
***
*****
*******
*********
***********
*************
*************** */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment