Need help with SL api | Sololearn: Learn to code for FREE!


Need help with SL api Can I have an example code plz?

4/17/2021 10:30:48 PM


6 Answers

New Answer


Hello there! :) I changed a bit your code and now it's working :) I added relevant tags where I modified your code. If it's not clear, I can try to explain it more detailed :)


CamelBeatsSnake oh yes good catch!


doing "else if" (line 9) fixed the problem, but still, that's odd since it should detect empty strings anyway.


「HAPPY TO HELP」 and Twin Chick 🐣🐣🐣🐤🐤🐤🐥🐥🐥 it's because userId is given a number value on line 6. You can't call includes on a number.


You are trying to assign an integer value to the string variable userId ☺️ It should be: userId = "21344701" You can shorten the code: var userId = prompt("Enter your id (Leave it blank if you want MY id.)") || "21344701";


Twin Chick 🐣🐣🐣🐤🐤🐤🐥🐥🐥 You might want to do some error handling with this. If I enter a string value in the prompt, there's an uncaught error on line 22. In fact, all the lines below that (apart from window.onload obviously) will fail because you won't have a userDetails property on the data you get back.