diff --git a/solutions/8.js b/solutions/8.js index 16d6ed8..9328029 100644 --- a/solutions/8.js +++ b/solutions/8.js @@ -9,6 +9,19 @@ const solution = (string) => { return newString; }; +// Maricris Bonzo: seemcat + +const solution1 = (string) => { + let indexLength = string.length - 1; + let reverseString = ''; + + for(i = 0; i <= indexLength; i++){ + reverseString = string[i] + reverseString; + } + return reverseString; +}; + module.exports = { solution, + solution1 }; diff --git a/test/8.js b/test/8.js index edb956b..b98b36f 100644 --- a/test/8.js +++ b/test/8.js @@ -1,6 +1,7 @@ const expect = require('chai').expect; let solution = require('../solutions/8').solution; -solution = require('../yourSolution').solution; +let solution1 = require('../solutions/8').solution1; +// solution = require('./yourSolution').solution; describe('reverse String', () => { it('should reverse a string in reverse', () => { @@ -23,4 +24,25 @@ describe('reverse String', () => { const expected = "welcome emoclew"; expect(solution(actual)).to.equal(expected); }); + it('should reverse a string in reverse', () => { + const actual = "react"; + const expected = "tcaer"; + expect(solution1(actual)).to.equal(expected); + }); + it('should reverse a string in reverse', () => { + const actual = "word"; + const expected = "drow"; + expect(solution1(actual)).to.equal(expected); + }); + it('should reverse a string in reverse', () => { + const actual = "I"; + const expected = "I"; + expect(solution1(actual)).to.equal(expected); + }); + it('should reverse a string in reverse', () => { + const actual = "welcome emoclew"; + const expected = "welcome emoclew"; + expect(solution1(actual)).to.equal(expected); + }); + });