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:
committed by
Randell Dawson
parent
fdaff91ed7
commit
83c9258bed
@ -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>
|
||||
|
||||
##  Advanced Code Solution:
|
||||
|
||||
function repeatStringNumTimes(str, num) {
|
||||
return num > 0 ? str.repeat(num) : '';
|
||||
}
|
||||
|
||||
repeatStringNumTimes("abc", 3);
|
||||
|
||||
 <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>
|
||||
|
||||
##  NOTES FOR CONTRIBUTIONS:
|
||||
|
||||
*  **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.
|
||||
|
Reference in New Issue
Block a user