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

+3

Need help with SL api

https://code.sololearn.com/Wj19CZi7D04s/?ref=app Can I have an example code plz?

4/17/2021 10:30:48 PM

Hello

6 Answers

New Answer

+8

Hello there! :) I changed a bit your code and now it's working :) https://code.sololearn.com/WfDLevapDYdb/?ref=app I added relevant tags where I modified your code. If it's not clear, I can try to explain it more detailed :)

+4

CamelBeatsSnake oh yes good catch!

+3

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

+3

「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.

+2

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";

+2

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.