Last active
April 3, 2017 23:56
-
-
Save juliozuppa/c8e1b6f6021d198d6a1cf78cebd4f20c 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
/** | |
* Repete a string informada no parâmetro str | |
* a quantidade de vezes informada no parâmetro num | |
* @param {string} str - a String a ser repetida | |
* @param {int} num - o número de vezes a repetir | |
* @returns {string} | |
*/ | |
function repeat(str, num) { | |
var arr = [], i = 0; | |
while (i < num) { arr[i++] = str; } | |
return arr.join(''); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment