Modify if statement (#36088)
* Modify if statement Change the solution so an empty string is returned when num is less than 1 rather than less than 0 for consistency with instructions. * Add test New test checks that if num is 0, an empty string is returned * Fix test Fixing errors in newly proposed test that checks that empty string is returned when num is 0 * Modify intermediate solution Changing if statement in intermediate solution to check whether num is less than 1 rather than less than 0. (Also adding curly brackets to that solutions if/else statements.) * fix: removed unnecessary assert message arguments
This commit is contained in:
committed by
Manish Giri
parent
39c43dbe8a
commit
545b8a6f34
@@ -65,12 +65,13 @@ Make the variable created store the current value and append the word to it.
|
||||
##  Intermediate Code Solution:
|
||||
|
||||
function repeatStringNumTimes(str, num) {
|
||||
if(num < 0)
|
||||
if (num < 1) {
|
||||
return "";
|
||||
if(num === 1)
|
||||
} else if (num === 1) {
|
||||
return str;
|
||||
else
|
||||
} else {
|
||||
return str + repeatStringNumTimes(str, num - 1);
|
||||
}
|
||||
}
|
||||
|
||||
 <a href='https://repl.it/CLjU/21' target='_blank' rel='nofollow'>Run Code</a>
|
||||
|
Reference in New Issue
Block a user