diff --git a/src/index.js b/src/index.js index 243d154..dd8c59e 100644 --- a/src/index.js +++ b/src/index.js @@ -5,7 +5,12 @@ */ const hammingDistance = (a, b) => { - - } + if(a.length != b.length) + throw new TypeError('Strings of different lengths'); + const arrayA = a.split(''); + const arrayB = b.split(''); + return arrayA.reduce((acc, current, index) => ( + current !== arrayB[index] ? ++acc : acc),0) +} module.exports = hammingDistance; \ No newline at end of file