Nice one, but there are some things that bother me in the code.
You could have replaced the var by a let or a const in the first line since you are using let later.
You can increase the speed execution of your algorithm by caching the length of the prices variables, which is not changing over the course of your iterations.
Your variable maxCurr lacks a variable declaration keyword: either let or const.
Also, you are using the maxCurr variable before even declaring it. That does not make sense.
I tried to run it but it threw some exceptions, did you run it on your local machine?
Nice one, but there are some things that bother me in the code.
You could have replaced the
var
by alet
or aconst
in the first line since you are usinglet
later.You can increase the speed execution of your algorithm by caching the length of the
prices
variables, which is not changing over the course of your iterations.Your variable
maxCurr
lacks a variable declaration keyword: eitherlet
orconst
.Also, you are using the
maxCurr
variable before even declaring it. That does not make sense.I tried to run it but it threw some exceptions, did you run it on your local machine?
Thanks for pointing out, it's a typo. My bad. I have updated the code.