Javascript interpreter acting funny

Hello,

Today I noticed that I kept getting unexpected results when trying to revisit some challenges. I ended up clearing my cache and I’m currently using an up to date version of Chrome.

My problem is that if I try to use map or filter for a challenge under intermediate JS algorithms, the functions dont work. I have re read my code over and over and everything is typed correctly, I have tried arrow functions and non arrow functions. I know I’m using map correctly because when I launch a node termial I get my expected output.

Is there any reason why the JS interpreter wouldn’t be performing map or filter properly?

Thank you

EDIT: If I create an array, then use map and console.log the array it shows the array unchanged. If I console.log the whole array.map operation I get the expected results. This didn’t always use to be how the interpreter behaved. Is there a chrome compiler update or some reason why this behavior is implemented?

The map method returns a new array, doesn’t change the original array, so what you are experiencing is normal. There are a few methods that change the array on which are used, not this one.

2 Likes

I literally thought about that just a few minutes ago. I really appreciate your help and feel dumb for posting this.

1 Like