This only occurs in conjunction with the es2015 plugin.
The following code
function getSum(data) {
let total = 0;
for (let i = 0; i < data.length; i++) {
total += data[i];
}
return total;
}
gets transpiled to
"use strict";function getSum(a){for(var c=0;c<a.length;c++)a[c];return b}
which returns the undefined variable b. Seemingly total has been removed.
The same code using var i instead of let i produces the expected result
"use strict";function getSum(a){for(var c=0,b=0;b<a.length;b++)c+=a[b];return c}
This only occurs in conjunction with the es2015 plugin.
The following code
gets transpiled to
which returns the undefined variable
b. Seeminglytotalhas been removed.The same code using
var iinstead oflet iproduces the expected result