Last active
January 19, 2018 13:39
-
-
Save leleofg/b54382691b7bb4fef84f36f2fd0949aa 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
| var string = "abcd"; | |
| var array = string.split(""); | |
| for(i=0; i<array.length;i++){ | |
| str = array[i].repeat(i+1); | |
| if(str.length == 1) { | |
| console.log(str.toUpperCase()); | |
| } else { | |
| primeira_posicao = str.substring(0,1); | |
| letra_grande = primeira_posicao.toUpperCase(); | |
| str = str.substring(1,(str.length)); | |
| console.log(letra_grande + str); | |
| } | |
| } | |
| // return: | |
| // A | |
| // Bb | |
| // Ccc | |
| // Dddd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment