Give users lives and gender

3197 views javascript

I'm pretty new to javascript/dom scripting and I'm doing small projects to get better. My idea was a Truth or Dare'ish game where you can add as many users as you want, after that the users will get added to this Winwheel: "". Then you spin the wheel and you get "x player has to this".

My first thought was to add all users to an array, but my problem is I want all players to have a health system if you want to skip your turn, and every user has 3 lives. and I also want to store if the user is a boy or a girl. How can I Store info as lives for each individual, and gender when all the users are stored in an array?

answered question

You do it the same way as without an array.

Care to elaborate?

@Tweey Each user could be represented by a standard JavaScript object, then you just add the objects to the list. I believe melpomene meant that the representation of the users is completely separate from how the users are stored. One doesn't effect the other.

1 Answer


You could store an array of objects! Each object would represent a user. So you could have a user object with this schema:

    name: 'John',
    lives: 3,
    gender: 'male'

And you could keep adding as many properties as you want.

Then you could push those items to an array. It would look like this:

        name: 'John',
        lives: 3,
        gender: 'male'
        name: 'Vanessa',
        lives: 2,
        gender: 'female'

Hope this helps!

posted this

Have an answer?


Please login first before posting an answer.