We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e221e60 commit 2feba68Copy full SHA for 2feba68
JavaScript/chapter01/1.5 - OneAway/rroque98_sol.js
@@ -23,15 +23,14 @@ const isOneAway = (str1, str2) => {
23
}
24
const longStr = str1.length > str2.length ? str1 : str2;
25
const shortStr = str1.length <= str2.length ? str1 : str2;
26
- for (let i = 0, x = 0; i < longStr.length && x < shortStr.length; i++, x++) {
27
- if (longStr[i] === shortStr[x]) {
+ for (let i = 0; i + errorCount < longStr.length; i++) {
+ if (longStr[i + errorCount] === shortStr[i]) {
28
continue;
29
30
errorCount++;
31
if (errorCount > 1) {
32
return false;
33
34
- i++;
35
36
return true;
37
};
0 commit comments