What's wrong with this code it doesn't run in but it works fine in my PC weird🤔 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

What's wrong with this code it doesn't run in but it works fine in my PC weird🤔

https://code.sololearn.com/W8qsybl22nrL/?ref=app

5th Aug 2022, 1:05 AM
Samuel Tadele
Samuel Tadele - avatar
15 Answers
+ 7
Glad to be of assistance. 😁
5th Aug 2022, 1:30 AM
Jeremiah Jahnke
Jeremiah Jahnke - avatar
+ 4
If you run the code using SoloLearn mobile app, then you need to wrap your code in JS section inside "load" event handler. Why? read here https://www.sololearn.com/post/90825/?ref=app window.onload = () => { // your code goes here } I also noticed some typos in JS section. Are you sure it works fine in your PC? if it did, then I find it weird as well. Line 22: squar -> square Line 58: origBord -> origBoard Line 78: aiplayer -> aiPlayer Line 81: avialSpots -> availsSpots Line 85, 87, 88, 99: availSpots -> availsSpots Line 92, 96: result.score is not recognised Line 101: move.push(move) -> moves.push(move)
5th Aug 2022, 1:33 AM
Ipang
+ 2
Yes, their not interpreting the code properly/maybe they don't support the use of .style or just .display. I'd have to run some tests to actually be sure of it.
5th Aug 2022, 1:26 AM
Jeremiah Jahnke
Jeremiah Jahnke - avatar
+ 1
The problem is in the JavaScript document.querySelector(".endgame").style.display = "none"; Is not working, I'm pretty sure it's saying that it can't find .endgame class or that .display is an invalid property.
5th Aug 2022, 1:21 AM
Jeremiah Jahnke
Jeremiah Jahnke - avatar
+ 1
That means the problem is with sololearn's platform not the code?
5th Aug 2022, 1:24 AM
Samuel Tadele
Samuel Tadele - avatar
+ 1
Samuel, By that statement, you claim the code (with all the typos in it) works fine in your PC? is that it? By right those typos should trigger the generation of error messages in console. It is weird if the code with those typos runs just fine. I guess you can now cease pointing finger at SoloLearn : )
5th Aug 2022, 1:52 AM
Ipang
+ 1
Samuel, One lesson learned. Next time, please post the code in original form to avoid misunderstanding. Just copy/paste the code as is. Good day ...
5th Aug 2022, 2:00 AM
Ipang
+ 1
Good game idea
6th Aug 2022, 8:14 PM
emma
emma - avatar
0
Thanks for your feedback!
5th Aug 2022, 1:28 AM
Samuel Tadele
Samuel Tadele - avatar
0
the typos are my mistake but null nah it works it doesn't show null error or any thing
5th Aug 2022, 1:47 AM
Samuel Tadele
Samuel Tadele - avatar
0
I've read the post he listed and from what I've seen it's because Sololearn interprets the code differently from your normal browser, also yes the typos are a problem.
5th Aug 2022, 1:50 AM
Jeremiah Jahnke
Jeremiah Jahnke - avatar
0
Jah i think you right
5th Aug 2022, 1:54 AM
Samuel Tadele
Samuel Tadele - avatar
0
Ipang: not with the typos the typos are my mistake when i wrote it on sololearn playground in my PC there are no typos everything is right no typo mistake
5th Aug 2022, 1:57 AM
Samuel Tadele
Samuel Tadele - avatar
0
Okay! thanks for your advice thou😊
5th Aug 2022, 2:02 AM
Samuel Tadele
Samuel Tadele - avatar
0
Sup
5th Aug 2022, 6:33 PM
Duquan Mccain