console.log changes function output value
I thought console.log doesn't change an output for function. Can someone explain why does this heppen?
function S(e) {
for (var t = '', n = e.charCodeAt(0), i = 1; i < e.length; ++i)
console.log(i, n );
t += String.fromCharCode(e.charCodeAt(i) ^ ((i + n) & 127));
return t;
}
S(":h_OWO4a'16*4g.&8kn") // return 'M'
and without using console.log completly different result
function S(e) {
for (var t = '', n = e.charCodeAt(0), i = 1; i < e.length; ++i)
t += String.fromCharCode(e.charCodeAt(i) ^ ((i + n) & 127));
return t;
}
S(":h_OWO4a'16*4g.&8kn") // return 'Script error for "'