diff --git a/src/index.js b/src/index.js index 243d154..55a20f5 100644 --- a/src/index.js +++ b/src/index.js @@ -5,7 +5,23 @@ */ const hammingDistance = (a, b) => { - + + let hammingDistance = 0 + + if (a.length == b.length) { + + for (i = 0; i < a.length; i++) { + + if(a.charAt(i) !== b.charAt(i)) { + hammingDistance++ + } + } + } else { + throw new Error('Sorry, I can not to compare it') + } + + return hammingDistance; +} } - module.exports = hammingDistance; \ No newline at end of file + module.exports = hammingDistance;