treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Better way to approach this Switch or Array scenario?

  • Hi everyone... pretty newbie at Javascript and Jquery and am trying to get better.

    I have a situation where I have two sets of buttons, one containing 5 buttons, the other containing 3 buttons. I have to do a mix n' match kind of page where if you pick one option, the page background and other elements (mainly images) will change base on the selections. Since I have two sets of buttons, I'll have 15 different possibilities.

    Since I'm not very good at this kind of stuff... I did a switch-case as a prototype so you can see where I'm going with this. I don't know how to structure an array to handle this kind of thing, so I guess that is part of my question.

    Is what I have currently the 'best' solution or would structuring this into an array object be better?

    My Pen: http://codepen.io/ahabion/pen/Eqyoc

  • An array or object would be easier to maintain I'd say.