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

18th Dec 2022, 8:38 AM
Creative Creations 1
Creative Creations 1 - avatar
5 Réponses
+ 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.
18th Dec 2022, 10:14 AM
PanicS
PanicS - avatar
+ 2
PanicS But try it on other compilers Sololearn is just a small compiler
19th Dec 2022, 7:59 AM
Creative Creations 1
Creative Creations 1 - avatar
+ 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
19th Dec 2022, 8:32 AM
PanicS
PanicS - avatar
+ 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
19th Dec 2022, 8:52 AM
PanicS
PanicS - avatar
+ 1
Yes it does
20th Dec 2022, 8:23 AM
Creative Creations 1
Creative Creations 1 - avatar