Skip to content
This repository was archived by the owner on Aug 1, 2021. It is now read-only.

Commit 198fe84

Browse files
eliaahadimatthewmorgan
authored andcommitted
reverse string exercise (#417)
* reverse string exercise * 3 files for submission * name updates * more updates * subject.matches is a function * fixed array inputs * modified matches * spacing updates * spacing updates #2 * spacing updates #3 * spacing updates #4 * config.json reverse string * updated spec and example files * updated spec and example files v2 * updated spec and example files v3 * updated spec and example files v4 * updated spec and example files v5 * updated spec and example files v6
1 parent 39bad1a commit 198fe84

File tree

4 files changed

+92
-0
lines changed

4 files changed

+92
-0
lines changed

config.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,18 @@
3535
],
3636
"uuid": "0c231a1c-55f7-47b6-8a54-ccae4ab0c65b"
3737
},
38+
{
39+
"core": false,
40+
"difficulty": 2,
41+
"slug": "reverse-string",
42+
"topics": [
43+
"loops",
44+
"for",
45+
"strings"
46+
],
47+
"unlocked_by": "leap",
48+
"uuid": "553a6be7-eecb-45dc-9cea-05126c525f1b"
49+
},
3850
{
3951
"core": true,
4052
"difficulty": 1,

exercises/reverse-string/README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Reverse String
2+
3+
For example:
4+
input: "cool"
5+
output: "looc"
6+
7+
8+
## Setup
9+
10+
Go through the setup instructions for JavaScript to
11+
install the necessary dependencies:
12+
13+
http://exercism.io/languages/javascript
14+
15+
## Making the Test Suite Pass
16+
17+
Execute the tests with:
18+
19+
jasmine <exercise-name>.spec.js
20+
21+
Replace `<exercise-name>` with the name of the current exercise. E.g., to
22+
test the Reverse String exercise:
23+
24+
jasmine reverse-string.spec.js
25+
26+
In many test suites all but the first test have been skipped.
27+
28+
Once you get a test passing, you can unskip the next one by
29+
changing `xit` to `it`.
30+
31+
## Source
32+
33+
This is an exercise to introduce users to using Exercism and arrays and strings [https://medium.freecodecamp.org/how-to-reverse-a-string-in-javascript-in-3-different-ways-75e4763c68cb](https://medium.freecodecamp.org/how-to-reverse-a-string-in-javascript-in-3-different-ways-75e4763c68cb)
34+
35+
## Submitting Incomplete Solutions
36+
It's possible to submit an incomplete solution so you can see how others have completed the exercise.

exercises/reverse-string/example.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
'use strict';
2+
3+
function reverseString(string) {
4+
var revString = '';
5+
for (var i = string.length - 1; i >= 0; i--) {
6+
revString += string[i];
7+
}
8+
return revString;
9+
}
10+
11+
module.exports = reverseString;
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
var reverseString = require('./reverse-string');
2+
3+
describe('ReverseString', function () {
4+
it('empty string', function () {
5+
var expected = '';
6+
var actual = reverseString('');
7+
expect(actual).toEqual(expected);
8+
});
9+
10+
xit('a word', function () {
11+
var expected = 'tobor';
12+
var actual = reverseString('robot');
13+
expect(actual).toEqual(expected);
14+
});
15+
16+
xit('a capitalized word', function () {
17+
var expected = 'nemaR';
18+
var actual = reverseString('Ramen');
19+
expect(actual).toEqual(expected);
20+
});
21+
22+
xit('a sentence with punctuation', function () {
23+
var expected = '!yrgnuh ma I';
24+
var actual = reverseString('I am hungry!');
25+
expect(actual).toEqual(expected);
26+
});
27+
28+
xit('a palindrome', function () {
29+
var expected = 'racecar';
30+
var actual = reverseString('racecar');
31+
expect(actual).toEqual(expected);
32+
});
33+
});

0 commit comments

Comments
 (0)