Starting exrcise

This commit is contained in:
billalp 2019-11-03 22:34:32 +00:00
parent 3feecab5eb
commit caf69daa5f
2 changed files with 5 additions and 6 deletions

View File

@ -6,13 +6,8 @@ Write a function that simply repeats the string a given number of times:
repeatString('hey', 3) // returns 'heyheyhey' repeatString('hey', 3) // returns 'heyheyhey'
``` ```
You will notice in this exercise that there are multiple tests (see in file `repeatString.spec.js`). Only the first test is currently enabled. So after making sure that this first one passes, enable the others one by one by deleting the `x` in front of the `it()` function.
## Hints ## Hints
- You're going to want to use a loop for this one. - You're going to want to use a loop for this one.
- Create a variable to hold the string you're going to return, create a loop that repeats the given number of times and add the given string to the result on each loop. - Create a variable to hold the string you're going to return, create a loop that repeats the given number of times and add the given string to the result on each loop.
- If running `jasmine repeatString.spec.js` raises `Temporarily disabled with xit` errors, make sure you have enabled the rest of the tests (see above).

View File

@ -4,15 +4,19 @@ describe('repeatString', function() {
it('repeats the string', function() { it('repeats the string', function() {
expect(repeatString('hey', 3)).toEqual('heyheyhey'); expect(repeatString('hey', 3)).toEqual('heyheyhey');
}); });
xit('repeats the string many times', function() { xit('repeats the string many times', function() {
expect(repeatString('hey', 10)).toEqual('heyheyheyheyheyheyheyheyheyhey'); expect(repeatString('hey', 10)).toEqual('heyheyheyheyheyheyheyheyheyhey');
}); });
xit('repeats the string 1 times', function() { xit('repeats the string 1 times', function() {
expect(repeatString('hey', 1)).toEqual('hey'); expect(repeatString('hey', 1)).toEqual('hey');
}); });
xit('repeats the string 0 times', function() { xit('repeats the string 0 times', function() {
expect(repeatString('hey', 0)).toEqual(''); expect(repeatString('hey', 0)).toEqual('');
}); });
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');
}); });