From c2fff5181efbdba16ce0f7b1208ea6f370093a4a Mon Sep 17 00:00:00 2001 From: eliaahadi Date: Wed, 11 Oct 2017 18:15:11 -0700 Subject: [PATCH 01/18] reverse string exercise --- exercises/reverse-string/README.md | 106 ++++++++++++++++++ .../reverse-string/canonical-schema.json | 54 +++++++++ exercises/reverse-string/description.md | 1 + exercises/reverse-string/metadata.yml | 5 + exercises/reverse-string/reverse-string.js | 15 +++ .../reverse-string/reverse-string.spec.js | 51 +++++++++ 6 files changed, 232 insertions(+) create mode 100644 exercises/reverse-string/README.md create mode 100644 exercises/reverse-string/canonical-schema.json create mode 100644 exercises/reverse-string/description.md create mode 100644 exercises/reverse-string/metadata.yml create mode 100644 exercises/reverse-string/reverse-string.js create mode 100644 exercises/reverse-string/reverse-string.spec.js diff --git a/exercises/reverse-string/README.md b/exercises/reverse-string/README.md new file mode 100644 index 00000000..7b046b5b --- /dev/null +++ b/exercises/reverse-string/README.md @@ -0,0 +1,106 @@ +# Reverse String + +The introductory exercise to arrays and strings. Just reverse input string. + +This is a typical first program for beginning programming in a new language +or environment after being able to do simple tasks. + +The objectives are simple: + +- Write a function that reverses the input string. +- Run the test suite and make sure that it succeeds. +- Submit your solution and check it at the website. + +If everything goes well, you will be ready to fetch your first real exercise. + +## Tutorial + +This exercise has two files: + +- reverse-string.js +- reverse-string.spec.js + +The first file is where you will write your code. +The second is where the tests are defined. + +The tests will check whether your code is doing the right thing. +You don't need to be able to write a test suite from scratch, +but it helps to understand what a test looks like, and what +it is doing. + +Open up the test file, reverse-string.spec.js. +There is one test inside: + + xit('detects simple reverse string', function () { + var subject = new ReverseString('ant'); + var matches = subject.matches(['tna']); + + expect(matches).toEqual(['tna']); + }); + +Run the test now, with the following command on the command-line: + + jasmine reverse-string.spec.js + +The test fails, which makes sense since you've not written any code yet. + +The failure looks like this: + + 1) Reverse String says reverse string + Message: + Expected undefined to equal 'tna'. + +There's more, but this is the most important part. + +Take a look at that first line: + + 1) Reverse String says reverse string + +Now look at the test definition again: + + it('detects simple reverse string', function() { + // ... more code here ... + }); + +Update the code and then run the tests again from the command-line: + + jasmine reverse-string.spec.js + +Notice how it changes the failure message. + +Then change the implementation in reverse-string.js again, this time to make the test pass. + +When you are done, submit your solution to exercism: + + exercism submit reverse-string.js + + +## Setup + +Go through the setup instructions for JavaScript to +install the necessary dependencies: + +http://exercism.io/languages/javascript + +## Making the Test Suite Pass + +Execute the tests with: + + jasmine .spec.js + +Replace `` with the name of the current exercise. E.g., to +test the Reverse String exercise: + + jasmine reverse-string.spec.js + +In many test suites all but the first test have been skipped. + +Once you get a test passing, you can unskip the next one by +changing `xit` to `it`. + +## Source + +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) + +## Submitting Incomplete Solutions +It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/reverse-string/canonical-schema.json b/exercises/reverse-string/canonical-schema.json new file mode 100644 index 00000000..33cc26ec --- /dev/null +++ b/exercises/reverse-string/canonical-schema.json @@ -0,0 +1,54 @@ +{ + "exercise": "revere-string", + "version": "1.0.1", + "comments": [ + "The string argument cases possible matches are passed in as", + "individual arguments rather than arrays. Languages can include", + "these string argument cases if passing individual arguments is", + "idiomatic in that language." + ], + "cases": [ + { + "description": "no matches", + "property": "reverse-string", + "subject": "car", + "candidates": ["girl", "Japan", "bear", "candy"], + "expected": [] + }, + { + "description": "detects simple reverse string", + "property": "reverse-string", + "subject": "ant", + "candidates": ["tna"], + "expected": ["tan"] + }, + { + "description": "detects reverse-string", + "property": "reverse-string", + "subject": "listen", + "candidates": ["netsil"], + "expected": ["netsil"] + }, + { + "description": "detects anagrams case-insensitively", + "property": "reverse-string", + "subject": "NinJa", + "candidates": ["ajnin"], + "expected": ["ajnin"] + }, + { + "description": "matches() accepts string arguments", + "property": "reverse-string", + "subject": "ant", + "candidates": ["tna"], + "expected": ["tna"] + }, + { + "description": "matches() accepts single string argument", + "property": "reverse-string", + "subject": "ant", + "candidates": ["ant"], + "expected": ["tna"] + } + ] +} \ No newline at end of file diff --git a/exercises/reverse-string/description.md b/exercises/reverse-string/description.md new file mode 100644 index 00000000..e49b125e --- /dev/null +++ b/exercises/reverse-string/description.md @@ -0,0 +1 @@ +With an input string, write code to reverse the string letters and return a string with reversed letters. Be sure to include error handling for an input that isn’t a string such as number or null values for inputs. \ No newline at end of file diff --git a/exercises/reverse-string/metadata.yml b/exercises/reverse-string/metadata.yml new file mode 100644 index 00000000..5ae26bf0 --- /dev/null +++ b/exercises/reverse-string/metadata.yml @@ -0,0 +1,5 @@ +--- +blurb: "Given a string, reverse it’s letters and output a new string." +title: "reverse-string" +source: "Common introductory challenge to learn loops and strings" +source_url: "https://medium.freecodecamp.org/how-to-reverse-a-string-in-javascript-in-3-different-ways-75e4763c68cb" \ No newline at end of file diff --git a/exercises/reverse-string/reverse-string.js b/exercises/reverse-string/reverse-string.js new file mode 100644 index 00000000..f161a16d --- /dev/null +++ b/exercises/reverse-string/reverse-string.js @@ -0,0 +1,15 @@ +// +// This is a stub file for the 'Reverse String' exercise. It's been provided as a +// convenience to get you started writing code faster. +// Make sure to look at reverse-string.spec.js--that should give you some hints about what is +// expected here. + +var ReverseString = function () {}; + +ReverseString.prototype.reverse = function () { +// +// YOUR CODE GOES HERE +// +}; + +module.exports = ReverseString; diff --git a/exercises/reverse-string/reverse-string.spec.js b/exercises/reverse-string/reverse-string.spec.js new file mode 100644 index 00000000..e6cfbbf2 --- /dev/null +++ b/exercises/reverse-string/reverse-string.spec.js @@ -0,0 +1,51 @@ +var ReverseString = require('./reverse-string'); + +describe('ReverseString', function () { + it('no matches', function () { + var subject = new ReverseString('car'); + var matches = subject.matches([ 'girl', 'Japan', 'bear', 'candy']); + + expect(matches).toEqual([]); + }); + + xit('detects simple reverse string', function () { + var subject = new ReverseString('ant'); + var matches = subject.matches(['tna']); + + expect(matches).toEqual(['tna']); + }); + + + + xit('detects anagram', function () { + var subject = new ReverseString('listen'); + var matches = subject.matches(['netsil']); + + expect(matches).toEqual(['netsil']); + }); + + + + xit('detects anagrams case-insensitively', function () { + var subject = new ReverseString('NinJa'); + var matches = subject.matches(['ajnin']); + + expect(matches).toEqual(['ajnin']); + }); + + + + xit('matches() accepts string arguments', function () { + var subject = new ReverseString('ant'); + var matches = subject.matches('tna'); + + expect(matches).toEqual(['tna']); + }); + + xit('matches() accepts single string argument', function () { + var subject = new ReverseString('ant'); + var matches = subject.matches('tna'); + + expect(matches).toEqual(['tna']); + }); +}); \ No newline at end of file From 839d560a3b04a30bd0550e086b073cdaf3937c17 Mon Sep 17 00:00:00 2001 From: eliaahadi Date: Mon, 27 Nov 2017 11:05:02 +1100 Subject: [PATCH 02/18] 3 files for submission --- exercises/reverse-string/example.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 exercises/reverse-string/example.js diff --git a/exercises/reverse-string/example.js b/exercises/reverse-string/example.js new file mode 100644 index 00000000..2b9180d6 --- /dev/null +++ b/exercises/reverse-string/example.js @@ -0,0 +1,14 @@ +'use strict'; + +function reverseString(s) {} + +ReverseString.prototype.convert = function (s) { + + var rString = ''; + for (var i=s.length-1; i>=0; i--){ + rString += s[i]; + } + return rString; +}; + +module.exports = ReverseString; From c5dc769f2c2ff86d869b500dfb9811f6098f93b3 Mon Sep 17 00:00:00 2001 From: eliaahadi Date: Tue, 28 Nov 2017 09:20:36 +1100 Subject: [PATCH 03/18] name updates --- exercises/reverse-string/README.md | 76 +------------------ .../reverse-string/canonical-schema.json | 54 ------------- exercises/reverse-string/description.md | 1 - exercises/reverse-string/example.js | 12 +-- exercises/reverse-string/metadata.yml | 5 -- exercises/reverse-string/reverse-string.js | 15 ---- .../reverse-string/reverse-string.spec.js | 50 +++++------- 7 files changed, 30 insertions(+), 183 deletions(-) delete mode 100644 exercises/reverse-string/canonical-schema.json delete mode 100644 exercises/reverse-string/description.md delete mode 100644 exercises/reverse-string/metadata.yml delete mode 100644 exercises/reverse-string/reverse-string.js diff --git a/exercises/reverse-string/README.md b/exercises/reverse-string/README.md index 7b046b5b..d6d75bb9 100644 --- a/exercises/reverse-string/README.md +++ b/exercises/reverse-string/README.md @@ -1,78 +1,8 @@ # Reverse String -The introductory exercise to arrays and strings. Just reverse input string. - -This is a typical first program for beginning programming in a new language -or environment after being able to do simple tasks. - -The objectives are simple: - -- Write a function that reverses the input string. -- Run the test suite and make sure that it succeeds. -- Submit your solution and check it at the website. - -If everything goes well, you will be ready to fetch your first real exercise. - -## Tutorial - -This exercise has two files: - -- reverse-string.js -- reverse-string.spec.js - -The first file is where you will write your code. -The second is where the tests are defined. - -The tests will check whether your code is doing the right thing. -You don't need to be able to write a test suite from scratch, -but it helps to understand what a test looks like, and what -it is doing. - -Open up the test file, reverse-string.spec.js. -There is one test inside: - - xit('detects simple reverse string', function () { - var subject = new ReverseString('ant'); - var matches = subject.matches(['tna']); - - expect(matches).toEqual(['tna']); - }); - -Run the test now, with the following command on the command-line: - - jasmine reverse-string.spec.js - -The test fails, which makes sense since you've not written any code yet. - -The failure looks like this: - - 1) Reverse String says reverse string - Message: - Expected undefined to equal 'tna'. - -There's more, but this is the most important part. - -Take a look at that first line: - - 1) Reverse String says reverse string - -Now look at the test definition again: - - it('detects simple reverse string', function() { - // ... more code here ... - }); - -Update the code and then run the tests again from the command-line: - - jasmine reverse-string.spec.js - -Notice how it changes the failure message. - -Then change the implementation in reverse-string.js again, this time to make the test pass. - -When you are done, submit your solution to exercism: - - exercism submit reverse-string.js +For example: +input: "cool" +output: "looc" ## Setup diff --git a/exercises/reverse-string/canonical-schema.json b/exercises/reverse-string/canonical-schema.json deleted file mode 100644 index 33cc26ec..00000000 --- a/exercises/reverse-string/canonical-schema.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "exercise": "revere-string", - "version": "1.0.1", - "comments": [ - "The string argument cases possible matches are passed in as", - "individual arguments rather than arrays. Languages can include", - "these string argument cases if passing individual arguments is", - "idiomatic in that language." - ], - "cases": [ - { - "description": "no matches", - "property": "reverse-string", - "subject": "car", - "candidates": ["girl", "Japan", "bear", "candy"], - "expected": [] - }, - { - "description": "detects simple reverse string", - "property": "reverse-string", - "subject": "ant", - "candidates": ["tna"], - "expected": ["tan"] - }, - { - "description": "detects reverse-string", - "property": "reverse-string", - "subject": "listen", - "candidates": ["netsil"], - "expected": ["netsil"] - }, - { - "description": "detects anagrams case-insensitively", - "property": "reverse-string", - "subject": "NinJa", - "candidates": ["ajnin"], - "expected": ["ajnin"] - }, - { - "description": "matches() accepts string arguments", - "property": "reverse-string", - "subject": "ant", - "candidates": ["tna"], - "expected": ["tna"] - }, - { - "description": "matches() accepts single string argument", - "property": "reverse-string", - "subject": "ant", - "candidates": ["ant"], - "expected": ["tna"] - } - ] -} \ No newline at end of file diff --git a/exercises/reverse-string/description.md b/exercises/reverse-string/description.md deleted file mode 100644 index e49b125e..00000000 --- a/exercises/reverse-string/description.md +++ /dev/null @@ -1 +0,0 @@ -With an input string, write code to reverse the string letters and return a string with reversed letters. Be sure to include error handling for an input that isn’t a string such as number or null values for inputs. \ No newline at end of file diff --git a/exercises/reverse-string/example.js b/exercises/reverse-string/example.js index 2b9180d6..4cc41114 100644 --- a/exercises/reverse-string/example.js +++ b/exercises/reverse-string/example.js @@ -1,14 +1,14 @@ 'use strict'; -function reverseString(s) {} +function ReverseString(string) {} -ReverseString.prototype.convert = function (s) { +ReverseString.prototype.convert = function (string) { - var rString = ''; - for (var i=s.length-1; i>=0; i--){ - rString += s[i]; + var revString = ''; + for (var i=string.length-1; i>=0; i--){ + revString += string[i]; } - return rString; + return revString; }; module.exports = ReverseString; diff --git a/exercises/reverse-string/metadata.yml b/exercises/reverse-string/metadata.yml deleted file mode 100644 index 5ae26bf0..00000000 --- a/exercises/reverse-string/metadata.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -blurb: "Given a string, reverse it’s letters and output a new string." -title: "reverse-string" -source: "Common introductory challenge to learn loops and strings" -source_url: "https://medium.freecodecamp.org/how-to-reverse-a-string-in-javascript-in-3-different-ways-75e4763c68cb" \ No newline at end of file diff --git a/exercises/reverse-string/reverse-string.js b/exercises/reverse-string/reverse-string.js deleted file mode 100644 index f161a16d..00000000 --- a/exercises/reverse-string/reverse-string.js +++ /dev/null @@ -1,15 +0,0 @@ -// -// This is a stub file for the 'Reverse String' exercise. It's been provided as a -// convenience to get you started writing code faster. -// Make sure to look at reverse-string.spec.js--that should give you some hints about what is -// expected here. - -var ReverseString = function () {}; - -ReverseString.prototype.reverse = function () { -// -// YOUR CODE GOES HERE -// -}; - -module.exports = ReverseString; diff --git a/exercises/reverse-string/reverse-string.spec.js b/exercises/reverse-string/reverse-string.spec.js index e6cfbbf2..895d64e7 100644 --- a/exercises/reverse-string/reverse-string.spec.js +++ b/exercises/reverse-string/reverse-string.spec.js @@ -1,51 +1,43 @@ var ReverseString = require('./reverse-string'); describe('ReverseString', function () { - it('no matches', function () { - var subject = new ReverseString('car'); - var matches = subject.matches([ 'girl', 'Japan', 'bear', 'candy']); + it('empty string', function () { + var subject = new ReverseString(""); + var matches = subject.matches([ ""]); - expect(matches).toEqual([]); + expect(matches).toEqual([""]); }); - xit('detects simple reverse string', function () { - var subject = new ReverseString('ant'); - var matches = subject.matches(['tna']); + xit('a word', function () { + var subject = new ReverseString('robot'); + var matches = subject.matches(['tobor']); - expect(matches).toEqual(['tna']); + expect(matches).toEqual(['tobor']); }); + xit('a capitalized word', function () { + var subject = new ReverseString('Ramen'); + var matches = subject.matches(['nemaR']); - xit('detects anagram', function () { - var subject = new ReverseString('listen'); - var matches = subject.matches(['netsil']); - - expect(matches).toEqual(['netsil']); + expect(matches).toEqual(['nemaR']); }); + xit('a sentence with punctuation', function () { + var subject = new ReverseString("I'm hungry"); + var matches = subject.matches(["!!yrgnuh m'I"]); - xit('detects anagrams case-insensitively', function () { - var subject = new ReverseString('NinJa'); - var matches = subject.matches(['ajnin']); - - expect(matches).toEqual(['ajnin']); + expect(matches).toEqual(["!yrgnuh m'I"]); }); + xit('a palindrome', function () { + var subject = new ReverseString('racecar'); + var matches = subject.matches('racecar'); - xit('matches() accepts string arguments', function () { - var subject = new ReverseString('ant'); - var matches = subject.matches('tna'); - - expect(matches).toEqual(['tna']); + expect(matches).toEqual(['racecar']); }); - xit('matches() accepts single string argument', function () { - var subject = new ReverseString('ant'); - var matches = subject.matches('tna'); - expect(matches).toEqual(['tna']); - }); -}); \ No newline at end of file +}); From d6a092079baac0dd857092867dae5bd2691816b9 Mon Sep 17 00:00:00 2001 From: eliaahadi Date: Tue, 28 Nov 2017 09:47:38 +1100 Subject: [PATCH 04/18] more updates --- exercises/reverse-string/example.js | 4 +++- exercises/reverse-string/reverse-string.spec.js | 13 ++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/exercises/reverse-string/example.js b/exercises/reverse-string/example.js index 4cc41114..2d245bd0 100644 --- a/exercises/reverse-string/example.js +++ b/exercises/reverse-string/example.js @@ -1,6 +1,8 @@ 'use strict'; -function ReverseString(string) {} +function ReverseString(string) { + this.string = string; +} ReverseString.prototype.convert = function (string) { diff --git a/exercises/reverse-string/reverse-string.spec.js b/exercises/reverse-string/reverse-string.spec.js index 895d64e7..c1007edc 100644 --- a/exercises/reverse-string/reverse-string.spec.js +++ b/exercises/reverse-string/reverse-string.spec.js @@ -2,10 +2,10 @@ var ReverseString = require('./reverse-string'); describe('ReverseString', function () { it('empty string', function () { - var subject = new ReverseString(""); - var matches = subject.matches([ ""]); + var subject = new ReverseString(''); + var matches = subject.matches([ '']); - expect(matches).toEqual([""]); + expect(matches).toEqual(['']); }); xit('a word', function () { @@ -25,10 +25,10 @@ describe('ReverseString', function () { xit('a sentence with punctuation', function () { - var subject = new ReverseString("I'm hungry"); - var matches = subject.matches(["!!yrgnuh m'I"]); + var subject = new ReverseString('I am hungry!'); + var matches = subject.matches(['!yrgnuh ma I']); - expect(matches).toEqual(["!yrgnuh m'I"]); + expect(matches).toEqual(['!yrgnuh ma I']); }); @@ -39,5 +39,4 @@ describe('ReverseString', function () { expect(matches).toEqual(['racecar']); }); - }); From 307452116719ce6868e5299f1e6329c442e4d5d1 Mon Sep 17 00:00:00 2001 From: eliaahadi Date: Thu, 30 Nov 2017 08:55:37 +1100 Subject: [PATCH 05/18] subject.matches is a function --- exercises/reverse-string/example.js | 2 +- exercises/reverse-string/reverse-string.spec.js | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/exercises/reverse-string/example.js b/exercises/reverse-string/example.js index 2d245bd0..016752d7 100644 --- a/exercises/reverse-string/example.js +++ b/exercises/reverse-string/example.js @@ -4,7 +4,7 @@ function ReverseString(string) { this.string = string; } -ReverseString.prototype.convert = function (string) { +ReverseString.prototype.matches = function (string) { var revString = ''; for (var i=string.length-1; i>=0; i--){ diff --git a/exercises/reverse-string/reverse-string.spec.js b/exercises/reverse-string/reverse-string.spec.js index c1007edc..4a6e3767 100644 --- a/exercises/reverse-string/reverse-string.spec.js +++ b/exercises/reverse-string/reverse-string.spec.js @@ -15,7 +15,6 @@ describe('ReverseString', function () { expect(matches).toEqual(['tobor']); }); - xit('a capitalized word', function () { var subject = new ReverseString('Ramen'); var matches = subject.matches(['nemaR']); @@ -23,7 +22,6 @@ describe('ReverseString', function () { expect(matches).toEqual(['nemaR']); }); - xit('a sentence with punctuation', function () { var subject = new ReverseString('I am hungry!'); var matches = subject.matches(['!yrgnuh ma I']); @@ -31,7 +29,6 @@ describe('ReverseString', function () { expect(matches).toEqual(['!yrgnuh ma I']); }); - xit('a palindrome', function () { var subject = new ReverseString('racecar'); var matches = subject.matches('racecar'); From 585a0c3e180587778373c3d67afcafb64d469594 Mon Sep 17 00:00:00 2001 From: eliaahadi Date: Thu, 30 Nov 2017 09:06:02 +1100 Subject: [PATCH 06/18] fixed array inputs --- .../reverse-string/reverse-string.spec.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/exercises/reverse-string/reverse-string.spec.js b/exercises/reverse-string/reverse-string.spec.js index 4a6e3767..dbb33906 100644 --- a/exercises/reverse-string/reverse-string.spec.js +++ b/exercises/reverse-string/reverse-string.spec.js @@ -3,37 +3,37 @@ var ReverseString = require('./reverse-string'); describe('ReverseString', function () { it('empty string', function () { var subject = new ReverseString(''); - var matches = subject.matches([ '']); + var matches = subject.matches(''); - expect(matches).toEqual(['']); + expect(matches).toEqual(''); }); xit('a word', function () { var subject = new ReverseString('robot'); - var matches = subject.matches(['tobor']); + var matches = subject.matches('tobor'); - expect(matches).toEqual(['tobor']); + expect(matches).toEqual('tobor'); }); xit('a capitalized word', function () { var subject = new ReverseString('Ramen'); - var matches = subject.matches(['nemaR']); + var matches = subject.matches('nemaR'); - expect(matches).toEqual(['nemaR']); + expect(matches).toEqual('nemaR'); }); xit('a sentence with punctuation', function () { var subject = new ReverseString('I am hungry!'); - var matches = subject.matches(['!yrgnuh ma I']); + var matches = subject.matches('!yrgnuh ma I'); - expect(matches).toEqual(['!yrgnuh ma I']); + expect(matches).toEqual('!yrgnuh ma I'); }); xit('a palindrome', function () { var subject = new ReverseString('racecar'); var matches = subject.matches('racecar'); - expect(matches).toEqual(['racecar']); + expect(matches).toEqual('racecar'); }); }); From 22fb4617f124a1f255631eb32431e2868a047de3 Mon Sep 17 00:00:00 2001 From: eliaahadi Date: Thu, 30 Nov 2017 13:06:32 +1100 Subject: [PATCH 07/18] modified matches --- exercises/reverse-string/reverse-string.spec.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/exercises/reverse-string/reverse-string.spec.js b/exercises/reverse-string/reverse-string.spec.js index dbb33906..19ae2513 100644 --- a/exercises/reverse-string/reverse-string.spec.js +++ b/exercises/reverse-string/reverse-string.spec.js @@ -10,21 +10,21 @@ describe('ReverseString', function () { xit('a word', function () { var subject = new ReverseString('robot'); - var matches = subject.matches('tobor'); + var matches = subject.matches('robot'); expect(matches).toEqual('tobor'); }); xit('a capitalized word', function () { var subject = new ReverseString('Ramen'); - var matches = subject.matches('nemaR'); + var matches = subject.matches('Ramen'); expect(matches).toEqual('nemaR'); }); xit('a sentence with punctuation', function () { var subject = new ReverseString('I am hungry!'); - var matches = subject.matches('!yrgnuh ma I'); + var matches = subject.matches('I am hungry!'); expect(matches).toEqual('!yrgnuh ma I'); }); From 300c129fe8a9a7015a52ac9a04abe885367b85ed Mon Sep 17 00:00:00 2001 From: eliaahadi Date: Fri, 1 Dec 2017 08:00:02 +1100 Subject: [PATCH 08/18] spacing updates --- exercises/reverse-string/reverse-string.spec.js | 1 - 1 file changed, 1 deletion(-) diff --git a/exercises/reverse-string/reverse-string.spec.js b/exercises/reverse-string/reverse-string.spec.js index 19ae2513..87849a33 100644 --- a/exercises/reverse-string/reverse-string.spec.js +++ b/exercises/reverse-string/reverse-string.spec.js @@ -35,5 +35,4 @@ describe('ReverseString', function () { expect(matches).toEqual('racecar'); }); - }); From 1a390ddc5f5000818cc665876dc1d76b7520767f Mon Sep 17 00:00:00 2001 From: eliaahadi Date: Fri, 1 Dec 2017 08:03:39 +1100 Subject: [PATCH 09/18] spacing updates #2 --- exercises/reverse-string/example.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/exercises/reverse-string/example.js b/exercises/reverse-string/example.js index 016752d7..8d238b43 100644 --- a/exercises/reverse-string/example.js +++ b/exercises/reverse-string/example.js @@ -1,14 +1,13 @@ 'use strict'; function ReverseString(string) { - this.string = string; + this.string = string; } -ReverseString.prototype.matches = function (string) { - +ReverseString.prototype.matches=function(string){ var revString = ''; for (var i=string.length-1; i>=0; i--){ - revString += string[i]; + revString += string[i]; } return revString; }; From 808cf1131e6343a5149316b3d421a0e0c400f839 Mon Sep 17 00:00:00 2001 From: eliaahadi Date: Fri, 1 Dec 2017 08:08:42 +1100 Subject: [PATCH 10/18] spacing updates #3 --- exercises/reverse-string/example.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/exercises/reverse-string/example.js b/exercises/reverse-string/example.js index 8d238b43..8181fc92 100644 --- a/exercises/reverse-string/example.js +++ b/exercises/reverse-string/example.js @@ -4,10 +4,10 @@ function ReverseString(string) { this.string = string; } -ReverseString.prototype.matches=function(string){ +ReverseString.prototype.matches = function (string) { var revString = ''; - for (var i=string.length-1; i>=0; i--){ - revString += string[i]; + for (var i = string.length-1; i >= 0; i--) { + revString += string[i]; } return revString; }; From 3d07b604c6bea6415eb6f3b983c5da8063c5c05a Mon Sep 17 00:00:00 2001 From: eliaahadi Date: Fri, 1 Dec 2017 08:14:46 +1100 Subject: [PATCH 11/18] spacing updates #4 --- exercises/reverse-string/example.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/reverse-string/example.js b/exercises/reverse-string/example.js index 8181fc92..b9ae51dc 100644 --- a/exercises/reverse-string/example.js +++ b/exercises/reverse-string/example.js @@ -6,7 +6,7 @@ function ReverseString(string) { ReverseString.prototype.matches = function (string) { var revString = ''; - for (var i = string.length-1; i >= 0; i--) { + for (var i = string.length - 1; i >= 0; i--) { revString += string[i]; } return revString; From b432096297759701038b2ec80a259cca6edf7010 Mon Sep 17 00:00:00 2001 From: eliaahadi Date: Mon, 4 Dec 2017 12:22:42 +1100 Subject: [PATCH 12/18] config.json reverse string --- config.json | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/config.json b/config.json index e89cb8bb..abeca950 100644 --- a/config.json +++ b/config.json @@ -24,6 +24,18 @@ ], "uuid": "0c231a1c-55f7-47b6-8a54-ccae4ab0c65b" }, + { + "core": false, + "difficulty": 2, + "slug": "reverse-string", + "topics": [ + "loops", + "for", + "strings" + ], + "unlocked_by": "leap", + "uuid": "553a6be7-eecb-45dc-9cea-05126c525f1b" + }, { "core": true, "difficulty": 1, From 5cc8bafcb96107506f905d9fcbc852788e4a5389 Mon Sep 17 00:00:00 2001 From: eliaahadi Date: Mon, 25 Dec 2017 21:21:17 +1100 Subject: [PATCH 13/18] updated spec and example files --- exercises/reverse-string/example.js | 8 +--- .../reverse-string/reverse-string.spec.js | 44 ++++++++----------- 2 files changed, 21 insertions(+), 31 deletions(-) diff --git a/exercises/reverse-string/example.js b/exercises/reverse-string/example.js index b9ae51dc..05e70f89 100644 --- a/exercises/reverse-string/example.js +++ b/exercises/reverse-string/example.js @@ -1,15 +1,11 @@ 'use strict'; function ReverseString(string) { - this.string = string; -} - -ReverseString.prototype.matches = function (string) { var revString = ''; for (var i = string.length - 1; i >= 0; i--) { revString += string[i]; } return revString; -}; +} -module.exports = ReverseString; +module.exports = ReverseString; \ No newline at end of file diff --git a/exercises/reverse-string/reverse-string.spec.js b/exercises/reverse-string/reverse-string.spec.js index 87849a33..e80ec0a5 100644 --- a/exercises/reverse-string/reverse-string.spec.js +++ b/exercises/reverse-string/reverse-string.spec.js @@ -2,37 +2,31 @@ var ReverseString = require('./reverse-string'); describe('ReverseString', function () { it('empty string', function () { - var subject = new ReverseString(''); - var matches = subject.matches(''); - - expect(matches).toEqual(''); + var expected = ''; + var actual = ReverseString(''); + expect(actual).toEqual(expected); }); - - xit('a word', function () { - var subject = new ReverseString('robot'); - var matches = subject.matches('robot'); - - expect(matches).toEqual('tobor'); + it('a word', function () { + var expected = 'tac'; + var actual = ReverseString('cat'); + expect(actual).toEqual(expected); }); - xit('a capitalized word', function () { - var subject = new ReverseString('Ramen'); - var matches = subject.matches('Ramen'); - - expect(matches).toEqual('nemaR'); + it('a capitalized word', function () { + var expected = 'nemaR'; + var actual = ReverseString('Ramen'); + expect(actual).toEqual(expected); }); - xit('a sentence with punctuation', function () { - var subject = new ReverseString('I am hungry!'); - var matches = subject.matches('I am hungry!'); - - expect(matches).toEqual('!yrgnuh ma I'); + it('a sentence with punctuation', function () { + var expected = '!yrgnuh ma I'; + var actual = ReverseString('I am hungry!'); + expect(actual).toEqual(expected); }); - xit('a palindrome', function () { - var subject = new ReverseString('racecar'); - var matches = subject.matches('racecar'); - - expect(matches).toEqual('racecar'); + it('a palindrome', function () { + var expected = 'racecar'; + var actual = ReverseString('racecar'); + expect(actual).toEqual(expected); }); }); From 2a2cae8e838c3a2b5647a7859dcde8cae245f0a3 Mon Sep 17 00:00:00 2001 From: eliaahadi Date: Mon, 25 Dec 2017 21:46:23 +1100 Subject: [PATCH 14/18] updated spec and example files v2 --- exercises/reverse-string/example.js | 4 +-- .../reverse-string/reverse-string.spec.js | 30 +++++++++---------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/exercises/reverse-string/example.js b/exercises/reverse-string/example.js index 05e70f89..b19b8d8d 100644 --- a/exercises/reverse-string/example.js +++ b/exercises/reverse-string/example.js @@ -1,6 +1,6 @@ 'use strict'; -function ReverseString(string) { +function reverseString(string) { var revString = ''; for (var i = string.length - 1; i >= 0; i--) { revString += string[i]; @@ -8,4 +8,4 @@ function ReverseString(string) { return revString; } -module.exports = ReverseString; \ No newline at end of file +module.exports = reverseString; diff --git a/exercises/reverse-string/reverse-string.spec.js b/exercises/reverse-string/reverse-string.spec.js index e80ec0a5..f2005411 100644 --- a/exercises/reverse-string/reverse-string.spec.js +++ b/exercises/reverse-string/reverse-string.spec.js @@ -1,32 +1,32 @@ -var ReverseString = require('./reverse-string'); +var reverseString = require('./reverse-string'); describe('ReverseString', function () { it('empty string', function () { - var expected = ''; - var actual = ReverseString(''); + var expected = ''; + var actual = reverseString(''); expect(actual).toEqual(expected); }); it('a word', function () { - var expected = 'tac'; - var actual = ReverseString('cat'); - expect(actual).toEqual(expected); + var expected = 'tac'; + var actual = reverseString('cat'); + expect(actual).toEqual(expected); }); it('a capitalized word', function () { - var expected = 'nemaR'; - var actual = ReverseString('Ramen'); - expect(actual).toEqual(expected); + var expected = 'nemaR'; + var actual = reverseString('Ramen'); + expect(actual).toEqual(expected); }); it('a sentence with punctuation', function () { - var expected = '!yrgnuh ma I'; - var actual = ReverseString('I am hungry!'); - expect(actual).toEqual(expected); + var expected = '!yrgnuh ma I'; + var actual = reverseString('I am hungry!'); + expect(actual).toEqual(expected); }); it('a palindrome', function () { - var expected = 'racecar'; - var actual = ReverseString('racecar'); - expect(actual).toEqual(expected); + var expected = 'racecar'; + var actual = reverseString('racecar'); + expect(actual).toEqual(expected); }); }); From 96e1ec4471e41b914c527be028efee0c75cb2463 Mon Sep 17 00:00:00 2001 From: eliaahadi Date: Mon, 25 Dec 2017 23:05:39 +1100 Subject: [PATCH 15/18] updated spec and example files v3 --- exercises/reverse-string/reverse-string.spec.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/exercises/reverse-string/reverse-string.spec.js b/exercises/reverse-string/reverse-string.spec.js index f2005411..d4234de7 100644 --- a/exercises/reverse-string/reverse-string.spec.js +++ b/exercises/reverse-string/reverse-string.spec.js @@ -4,28 +4,29 @@ describe('ReverseString', function () { it('empty string', function () { var expected = ''; var actual = reverseString(''); - expect(actual).toEqual(expected); + expect(actual).toEqual(expected); }); + it('a word', function () { - var expected = 'tac'; - var actual = reverseString('cat'); + var expected = 'tobor'; + var actual = reverseString('robot'); expect(actual).toEqual(expected); }); it('a capitalized word', function () { - var expected = 'nemaR'; + var expected = 'nemaR'; var actual = reverseString('Ramen'); expect(actual).toEqual(expected); }); it('a sentence with punctuation', function () { - var expected = '!yrgnuh ma I'; + var expected = '!yrgnuh ma I'; var actual = reverseString('I am hungry!'); - expect(actual).toEqual(expected); + expect(actual).toEqual(expected); }); it('a palindrome', function () { - var expected = 'racecar'; + var expected = 'racecar'; var actual = reverseString('racecar'); expect(actual).toEqual(expected); }); From 2dd30400bc21390382735b9f5a5c6b3fd1691cd7 Mon Sep 17 00:00:00 2001 From: eliaahadi Date: Mon, 25 Dec 2017 23:13:52 +1100 Subject: [PATCH 16/18] updated spec and example files v4 --- exercises/reverse-string/reverse-string.spec.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/exercises/reverse-string/reverse-string.spec.js b/exercises/reverse-string/reverse-string.spec.js index d4234de7..3b364b5e 100644 --- a/exercises/reverse-string/reverse-string.spec.js +++ b/exercises/reverse-string/reverse-string.spec.js @@ -6,7 +6,7 @@ describe('ReverseString', function () { var actual = reverseString(''); expect(actual).toEqual(expected); }); - + it('a word', function () { var expected = 'tobor'; var actual = reverseString('robot'); @@ -20,13 +20,13 @@ describe('ReverseString', function () { }); it('a sentence with punctuation', function () { - var expected = '!yrgnuh ma I'; + var expected = '!yrgnuh ma I'; var actual = reverseString('I am hungry!'); expect(actual).toEqual(expected); }); it('a palindrome', function () { - var expected = 'racecar'; + var expected = 'racecar'; var actual = reverseString('racecar'); expect(actual).toEqual(expected); }); From 6c28184c4f574bcb2140011cdae7203b86aef42e Mon Sep 17 00:00:00 2001 From: eliaahadi Date: Mon, 25 Dec 2017 23:16:56 +1100 Subject: [PATCH 17/18] updated spec and example files v5 --- exercises/reverse-string/reverse-string.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/reverse-string/reverse-string.spec.js b/exercises/reverse-string/reverse-string.spec.js index 3b364b5e..d7cffb43 100644 --- a/exercises/reverse-string/reverse-string.spec.js +++ b/exercises/reverse-string/reverse-string.spec.js @@ -20,7 +20,7 @@ describe('ReverseString', function () { }); it('a sentence with punctuation', function () { - var expected = '!yrgnuh ma I'; + var expected = '!yrgnuh ma I'; var actual = reverseString('I am hungry!'); expect(actual).toEqual(expected); }); From 865832a78f63bc2d88cbf075178c0f6e1999d0b2 Mon Sep 17 00:00:00 2001 From: eliaahadi Date: Tue, 26 Dec 2017 23:48:33 +1000 Subject: [PATCH 18/18] updated spec and example files v6 --- exercises/reverse-string/reverse-string.spec.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/exercises/reverse-string/reverse-string.spec.js b/exercises/reverse-string/reverse-string.spec.js index d7cffb43..c6d6327c 100644 --- a/exercises/reverse-string/reverse-string.spec.js +++ b/exercises/reverse-string/reverse-string.spec.js @@ -7,25 +7,25 @@ describe('ReverseString', function () { expect(actual).toEqual(expected); }); - it('a word', function () { + xit('a word', function () { var expected = 'tobor'; var actual = reverseString('robot'); expect(actual).toEqual(expected); }); - it('a capitalized word', function () { + xit('a capitalized word', function () { var expected = 'nemaR'; var actual = reverseString('Ramen'); expect(actual).toEqual(expected); }); - it('a sentence with punctuation', function () { + xit('a sentence with punctuation', function () { var expected = '!yrgnuh ma I'; var actual = reverseString('I am hungry!'); expect(actual).toEqual(expected); }); - it('a palindrome', function () { + xit('a palindrome', function () { var expected = 'racecar'; var actual = reverseString('racecar'); expect(actual).toEqual(expected);