mirror of
https://github.com/10h30/odin-javascript-exercises.git
synced 2026-06-05 15:09:09 +09:00
Completed 1-4
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
const reverseString = function() {
|
||||
|
||||
const reverseString = function(string) {
|
||||
let newString =""
|
||||
for (i = string.length; i >=0 ; i--) {
|
||||
newString += string.charAt(i);
|
||||
}
|
||||
return newString;
|
||||
};
|
||||
|
||||
// Do not edit below this line
|
||||
|
||||
@@ -5,16 +5,16 @@ 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! Hello, Odinite.')).toEqual(
|
||||
'.etinidO ,olleH !cba !321'
|
||||
);
|
||||
});
|
||||
test.skip('works with blank strings', () => {
|
||||
test('works with blank strings', () => {
|
||||
expect(reverseString('')).toEqual('');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user