Update index.md (#35805)

The advanced solution does not meet problem criteria.
"The built-in repeat()-method should not be used"
This commit is contained in:
asims2404
2019-04-09 23:39:45 +01:00
committed by Randell Dawson
parent fdaff91ed7
commit 83c9258bed

View File

@ -86,25 +86,6 @@ Make the variable created store the current value and append the word to it.
* <a href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions#Recursion' target='_blank' rel='nofollow'>Functions - Recursion</a>
## ![:rotating_light:](https://forum.freecodecamp.com/images/emoji/emoji_one/rotating_light.png?v=3 ":rotating_light:") Advanced Code Solution:
function repeatStringNumTimes(str, num) {
return num > 0 ? str.repeat(num) : '';
}
repeatStringNumTimes("abc", 3);
![:rocket:](https://forum.freecodecamp.com/images/emoji/emoji_one/rocket.png?v=3 ":rocket:") <a href='https://repl.it/CLjU/85' target='_blank' rel='nofollow'>Run Code</a>
### Code Explanation:
* This solution takes a declarative approach.
* It is similar to the third solution, except it uses the ternary operator form of the `if` statement.
#### Relevant Links
* <a href='https://forum.freecodecamp.com/t/javascript-ternary-operator/15973' target='_blank' rel='nofollow'>JS Ternary</a>
## ![:clipboard:](https://forum.freecodecamp.com/images/emoji/emoji_one/clipboard.png?v=3 ":clipboard:") NOTES FOR CONTRIBUTIONS:
* ![:warning:](https://forum.freecodecamp.com/images/emoji/emoji_one/warning.png?v=3 ":warning:") **DO NOT** add solutions that are similar to any existing solutions. If you think it is **_similar but better_**, then try to merge (or replace) the existing similar solution.