Merge pull request #9 from BillalPatel/reverse-string
Starting challenge
This commit is contained in:
		
						commit
						3feecab5eb
					
				| 
						 | 
				
			
			@ -6,10 +6,4 @@ Pretty simple, write a function called `reverseString` that returns it's input,
 | 
			
		|||
reverseString('hello there') // returns 'ereht olleh'
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
You will notice in this exercise that there are multiple tests, after making the first one pass, enable the others one by one by deleting the `x` in front of the `it()` function.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
## Hints
 | 
			
		||||
Strings in JavaScript cannot be reversed directly so you're going to have to split it into something else first.. do the reversal and then join it back together into a string.
 | 
			
		||||
You will notice in this exercise that there are multiple tests, after making the first one pass, enable the others one by one by deleting the `x` in front of the `it()` function.
 | 
			
		||||
| 
						 | 
				
			
			@ -1,5 +1,9 @@
 | 
			
		|||
const reverseString = function() {
 | 
			
		||||
 | 
			
		||||
const reverseString = function(word) {
 | 
			
		||||
	return word
 | 
			
		||||
		.split('')
 | 
			
		||||
		.splice('')
 | 
			
		||||
		.reverse()
 | 
			
		||||
		.join('');
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
module.exports = reverseString
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,11 +5,11 @@ describe('reverseString', function() {
 | 
			
		|||
    expect(reverseString('hello')).toEqual('olleh');
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  xit('reverses multiple words', function() {
 | 
			
		||||
  it('reverses multiple words', function() {
 | 
			
		||||
    expect(reverseString('hello there')).toEqual('ereht olleh')
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
  xit('works with numbers and punctuation', function() {
 | 
			
		||||
  it('works with numbers and punctuation', function() {
 | 
			
		||||
    expect(reverseString('123! abc!')).toEqual('!cba !321')
 | 
			
		||||
  })
 | 
			
		||||
});
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue