Last active
September 8, 2020 05:45
-
-
Save ashwinkumar2438/1b25d5dfe6d98d48cc81866dd059f854 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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