Tell me what the problem is. If the lines are the same, then "1", and if not, then undefined. And I need to true or false.
function slowStringComparison(givenSignature, computedSignature, cb) { if (!givenSignature || !computedSignature || givenSignature.length !== computedSignature.length) { return cb(false); } var n = computedSignature.length; var signaturesMatch = true; for (var i = 0; i < n; i++) { signaturesMatch &= (computedSignature.charAt(i) == givenSignature.charAt(i)); } return cb(null, signaturesMatch);}
&&instead of bitwise - GrundycomputedSignature[i]instead of callingcharAt- Grundyfalse- do a break to the loop, since there is no sense to check further. Or use the logical &&:signaturesMatch = signaturesMatch && computedSignature[i] == givenSignature[i];- Grundy