Write a function that reverses strings

This commit is contained in:
borobor 2022-02-16 19:41:51 +01:00
parent d862b648ca
commit 034c0b6c1c
2 changed files with 8 additions and 5 deletions

View File

@ -1,5 +1,8 @@
const reverseString = function() {
const reverseString = function(string) {
let arr = string.split('');
arr.reverse();
let word = arr.join('');
return word;
};
// Do not edit below this line

View File

@ -5,14 +5,14 @@ describe('reverseString', () => {
expect(reverseString('hello')).toEqual('olleh');
});
test.skip('reverses multiple words', () => {
test('reverses multiple words', () => {
expect(reverseString('hello there')).toEqual('ereht olleh')
})
test.skip('works with numbers and punctuation', () => {
test('works with numbers and punctuation', () => {
expect(reverseString('123! abc!')).toEqual('!cba !321')
})
test.skip('works with blank strings', () => {
test('works with blank strings', () => {
expect(reverseString('')).toEqual('')
})
});