0
JavaScript Muchine learning code not working correctly.
I created a ML(Muchine learning) JavaScript code, but instead of outputting numbers as out put it's doing Undefined. Code is https://code.sololearn.com/WGEpHjStc8Ns/?ref=app
5 Answers
+ 3
Local storage don't work on sololearn, comment this code or run with browser(on pc or phone)
When I commented code related to local storage it show some number.
+ 2
PanicS But try it on other compilers
Sololearn is just a small compiler
+ 2
Your output is for some reason undefined, you set it to be "NAN" as string by default, so some if/else are changing this to be undefined(some value inside some if/else are undefined, and this is assigned to output probably) or this is some scope problem
Try to place log inside every if/else and check where this happen
We mostly get undefined when variable is not defined, so it can be scope problem(check did you close if/else at right place, or if function don't have return statement)
Maybe it is not problem with output variable, maybe it is with some value inside functions you have. So check does functions have values they need
+ 2
code work without localstorage and log just number,
and don't work with localstorage, so check does value exist inside localstorage before working with them, maybe thats why it is undefined
+ 1
Yes it does