Problems with object constructors | Sololearn: Learn to code for FREE!

+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

11/15/2017 10:04:44 PM

Jay

14 Answers

New Answer

0

Totally changed things to really play around. https://code.sololearn.com/W0SpGiJ3Vfzb/?ref=app

+5

Try this https://code.sololearn.com/WsT2RhL0Usnn/?ref=app

+4

And the update method doesn't update any object properties, use this.teamxPoints = n. And also the code doesn't call update method.

+2

I have looked at that before but it didnt help much. Thanks for the reponse anyway.

+2

To debug object on Code Playground, try, console.log(JSON.stringify(match1));

+2

Thanks guys for the answer. I will be posting the finished code soon

+1

Anyone?

+1

i dont mind @john

+1

calvin, i debugged outside of SL

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

0

This is a nice start. https://code.sololearn.com/W5BhMf8TMiMV/?ref=app

0

Link it here so I get notified. You're welcome. I learned a ton doing this.

-1

I'm going to attempt to solve it. Do you care if I use your example for my code?

-1

Updated code with comments.