please
I wrote a lil piece of code that simulates footie matches. Check the attachment.
It's not the full code I included, but just the part that matters. The actual code starts with the definition of variables firstteam, firstrank (an index to determine team strength) & points1 (for number of points in a season). There's variables like this for 6 teams in total.
The 2nd part of the code, at the top of the screenshot, is the part that simulates a single match with the use of a function. It first determines # of goals scored, and then for each goal compares the rating of both squads (+a random number to enable the weaker team to score despite having a lower skill index). It then loops till all goals have been 'divided' over the teams and a final score is published.
The third part of the code is a long list of matchups (a full competition schedule of 6 teams). This is the part that fails on me
For some reason the script stops right after the 3rd matchup. (as indicated with a red line in the screenshot). And I can't for the love of God figure out how I can make the script proceed after this
I presume it has to do with variables being re-defined. As the 4th matchup is where the 2nd matchday start and each team plays its 2nd match. But what the problem exactly is, I dunno.
I guessed it might be the points part, as thats the only variable that gets a new value every time I call the function, but when I changed that of the 4th match to points7 & points8, it still wouldn't go beyond the 3rd.
The box in the bottom right of the screenshot is what I see when I open the HTML page.
+1: Would be nice as well, if someone could tell me how to break lines, so it's not all clustered together.
I found on the internet a solution by going out of java and into html just to use <br>, but yeah... seems like a real bother if you gotta repeat that over a dozen times.
+2: the document.write thing at the very bottom also gives me a problem. Shows undefined instead of the value I want it to show. (it doesnt show in the code now, as like i said, it stops after the 3rd matchup line, but if i put it up I get this error).
NOTE: I've started getting into html & java just one and a half week ago. I'm naab, so make it easy