Solved problem 1

This commit is contained in:
Mohammed Nabeel 2020-07-02 09:27:26 +03:00
parent 5c39ba4078
commit f9b8d2d403
2 changed files with 43 additions and 32 deletions

View File

@ -1,4 +1,15 @@
const repeatString = function() { const repeatString = function(sourceString, stringCount) {
//Declare variable/s
let resultString = '';
// Create a for loop to repeat the string
for (let i = 0; i < stringCount; i++) {
resultString = resultString + sourceString;
}
return resultString;
} }

View File

@ -16,7 +16,7 @@ describe('repeatString', function() {
xit('returns ERROR with negative numbers', function() { xit('returns ERROR with negative numbers', function() {
expect(repeatString('hey', -1)).toEqual('ERROR'); expect(repeatString('hey', -1)).toEqual('ERROR');
}); });
xit('repeats the string a random amount of times', function () { xit('repeats the string a random amount of times', function() {
/*The number is generated by using Math.random to get a value from between /*The number is generated by using Math.random to get a value from between
0 to 1, when this is multiplied by 1000 and rounded down with Math.floor it 0 to 1, when this is multiplied by 1000 and rounded down with Math.floor it
equals a number between 0 to 999 (this number will change everytime you run equals a number between 0 to 999 (this number will change everytime you run