Problems with object constructors | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 7

Problems with object constructors

https://code.sololearn.com/WEP9dW9DdeK4/#html I am having an issue with trying to get my code to work. I am trying to make an object that includes the teams points as you can see at the "this.update" property. When i run the program it doesnt seem to give the points and it doesnt seem to even evaluate both teams goals. I want the team1Points and team2Points properties to be derived from an IF statement like this: if(team1Goals > team2Goals){ team1Points = 3; team2Points = 0; else if (team2Goals > team1Goals){ team2Points = 3; team1Points = 0; else if(team1Goals == team2Goals){ team1Points = 1; team2Points = 1; } akin to the 1 point for a draw, 3 points for a win, 0 points for a loss format

15th Nov 2017, 10:04 PM
Jay
Jay - avatar
14 Answers
0
Totally changed things to really play around. https://code.sololearn.com/W0SpGiJ3Vfzb/?ref=app
16th Nov 2017, 2:08 PM
John Wells
John Wells - avatar
16th Nov 2017, 1:12 AM
Calviղ
Calviղ - avatar
+ 4
And the update method doesn't update any object properties, use this.teamxPoints = n. And also the code doesn't call update method.
16th Nov 2017, 12:56 AM
Calviղ
Calviղ - avatar
+ 2
I have looked at that before but it didnt help much. Thanks for the reponse anyway.
16th Nov 2017, 12:52 AM
Jay
Jay - avatar
+ 2
To debug object on Code Playground, try, console.log(JSON.stringify(match1));
16th Nov 2017, 12:54 AM
Calviղ
Calviղ - avatar
+ 2
Thanks guys for the answer. I will be posting the finished code soon
16th Nov 2017, 5:10 PM
Jay
Jay - avatar
+ 1
Anyone?
15th Nov 2017, 10:46 PM
Jay
Jay - avatar
+ 1
i dont mind @john
16th Nov 2017, 12:55 AM
Jay
Jay - avatar
+ 1
calvin, i debugged outside of SL
16th Nov 2017, 12:57 AM
Jay
Jay - avatar
0
It's definitely a interesting question. I'm still learning JS so I don't have an answer. However, I have discovered some answers here. https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects
16th Nov 2017, 12:51 AM
John Wells
John Wells - avatar
16th Nov 2017, 1:50 AM
John Wells
John Wells - avatar
0
Link it here so I get notified. You're welcome. I learned a ton doing this.
16th Nov 2017, 5:12 PM
John Wells
John Wells - avatar
- 1
I'm going to attempt to solve it. Do you care if I use your example for my code?
16th Nov 2017, 12:54 AM
John Wells
John Wells - avatar
- 1
Updated code with comments.
16th Nov 2017, 2:37 AM
John Wells
John Wells - avatar