test 3 completed

This commit is contained in:
rajroushan6714 2023-08-23 21:03:03 +05:30
parent d884923686
commit e46b84fd0f
2 changed files with 23 additions and 4 deletions

View File

@ -1,5 +1,24 @@
const reverseString = function() {
const reverseString = function(string) {
return string.split("").reverse().join("");
//solution 2 :
// let array = string.split("");
// let n = string.length;
// for(let i = 0 ;i < n/2 ;i++){
// let temp = array[n - 1 - i];
// array[n - 1 - i] = array[i];
// array[i] = temp;
// }
// return array.join('');
// solution 3 :
// let array = string.split("");
// let n = string.length;
// let res = "";
// for(let i = n - 1 ; i >= 0 ;i--){
// res += array[i];
// }
// return res;
};
// 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('')
})
});