For ... let... of disallowed?

Hi. I am trying to do a for…let…of

for(let number of parts) {
if (isNaN(parseFloat(number))) valid = false;
// parts is an array of chars.

Which got converted on to…

for (let number of parts) {
if (window.CP.shouldStopExecution(4)) {
if (isNaN(parseFloat(number)))
valid = false;

Any way around this? I realise it is only in ECMA 6.0

Did you try Pen Settings > JavaScript -> JavaScript Preprocessor > Babel?

I don’t know which ES6 transformations Codepen is using but I assume all of ES2015.


That’s fixed it. Thanks for that. What is Babel?

It produces JavaScript that will run on older JS interpreters that only support ES5 or some of ES6. It also allows you to try out proposed language features that are experimental or slated to be added to future releases of JavaScript.


1 Like