Error | Sololearn: Learn to code for FREE!

+2

Error

Who does this code work for? Source Code from Russ: https://code.sololearn.com/WtQTIVaw748j/?ref=app

4/13/2020 10:50:01 PM

Vasiliy

23 Answers

New Answer

+2

No, I was thinking that the code was saved by you in sololearn... I don't know why the author say that his code run fine here (does he have really tested ?), because I use the code playground editor from years on both mobile devices and desktop, and the process had always be the same: the content of the js (and the css) tabs are dynamically inserted at the end of the <head> section of the html tab content before running... so, at this place, when the script is executed the DOM is not ready at all (you could access window and document objects, but you only could access the <head> part (not the <body> and its content, wich aren't be still read/parsed and DOM tree not already populated, appart code standing before the script tag): you need then to wait for the document load ends ;)

+3

So I am the creator of this code. Just to clear up any confusion; yes, this code works perfectly fine on iOS - both on iPhone and on iPad. It also worked on a free, downloaded iOS IDE without any issues. Thanks Vasiliy for flagging this up, though. I will always make sure I use the load event so that it should work for everyone πŸ‘

+2

SoloLearn automatically loads the script in the <head> portion of the HTML file instead of at the end of the body. This is why you are getting a null error. The elements of the body don't exist when the script is loaded. So you need to use the onload wrapper so that loading of the script file is forced after the page loads. That way the structure and elements of the page exists when it is ran.

+2

Vasiliy They're probably running it on their own machine and just copied the code here then. At least, that would be my guess.

+2

Thank you all, I satisfied my curiosity, otherwise I already began to doubt. πŸ™‹

+2

it runs on iphone just fine.

+2

iOS app is very different. Like 20-30% of the Web apps fail written for android fail on it.

+2

Code Crasher Please test this code: https://code.sololearn.com/WtQTIVaw748j/?ref=app Does it work for you?

+2

Vasiliy yes that code works just fine on 4 different devices. I have been frustrated with the inconsistency of the SL apps since the second week after I joined SL. the iPhone app is grossly deficient compared to the android app, and doesn't look similar at all. The web page is unusable in my opinion. I had to chuckle when an Android user complained code didn't work on their app... It is common that 1 out of 5 Hot and Trending Web apps fail to load on iPhone because they use Android devices to test. (There are 3 apps on the top 10 today, that fail) I shouldn't get pleasure from seeing the incompatibility, but after all the frustration it sometimes feels good for someone else to have the problem, I guess? The real answer is to get SL to fix code playground and get the apps and webpage to be more consistent cross platform?! πŸ˜‰

+2

Code Crasher The iOS apps have always been well behind the Android app as far as I've been around here too (over two years). When new features came out, people were always talking about them and I had no idea what they were on about because they weren't accessible to iOS users until 3-6 months down the line. There was a point when coding challenges were allowed to be posted by people in the Q&A forum and doing those challenges was something a lot of us enjoyed. They stopped that because they brought in a new feature (Challenge Factory or something), but it was months before it was even availbale to iOS. When SL brought in private messaging and we all had our own inboxes, by the time iOS had access to these PMs, I had messages around 6+ months old from people asking for help that I never knew about. I have no idea why it appears to be so hard to create an app for iOS in the same time frame as it does for Android, or why the web Code Playground appears to act differently. It's a lot better than it was though!

+2

Russ I have been seeing the pain points in the short time I have been on SL... you would think since they are getting more main stream attention and more users, that they would look at standardizing? The talent on this site is more than sufficient to create an HTML UI, and the hired developers could use a tool like phonegap (or now I guess it is Cordova?) to connect the backend and package the apps for all the platforms? They would have minimal effort to maintain the multiple platforms?! I bet a contest to improve the interface would pay huge dividends in acceptence of any changes and in the cost of any new development necessary?! 😱

+1

This code gives me an error, (line # 11). And how are you? This problem can be solved with the help of "onload=()=>{}"

+1

ChaoticDawg I think so too, but the author of this code stated that he had no problems. πŸ˜•

+1

Probably the original author doesn't run his code in a sololearn playground project, and doesn't know how things works here ;) If you don't want to wrap all the js tab in a onload function (clean way), you could cut / paste the whole content inside a <script> tag at the end of the <body> section of the html tab ^^

+1

visph, ChaoticDawg, do you do it from a smartphone? Maybe he is engaged in SoloLearn with a "computer"? Although it is unlikely that the script will load differently πŸ˜•

+1

mobile device or desktop, that doesn't matter: in each case the process is the same ^^

+1

visph ☺️ I did not understand right away, do you mean that there is another author? πŸ˜ƒ

+1

Code Crasher that's surprising, but probably the iOS app handle things differently :o

0

Code Crasher I would well believe the talent on here would be able to do the job but, at the end of the day, this is someone's business. Whoever created SL did so apparently without income for a long time and have only fairly recently started monetising it through advertising and memberships. It would be entirely up to them what they do with it. While a competition sounds like a good idea, I think that would mean passing control of the business to users to an extent, and I can't see them really wanting to do that.

0

Russ I didn't realize that the ads and membership were a new concept for SoloLearn. That is a shame, it is a good learning model. Hopefully, they can make the necessary changes before going broke?! 😳