diff --git a/src/index.js b/src/index.js index 243d154..068873d 100644 --- a/src/index.js +++ b/src/index.js @@ -6,6 +6,14 @@ const hammingDistance = (a, b) => { + if (a.length === b.length) { + const aArray = a.split(''); + const bArray = b.split(''); + return bArray.filter((letter, index) => aArray[index] !== letter).length + } else { + throw new Error("You must enter strings with the same length"); + } + } module.exports = hammingDistance; \ No newline at end of file