Grow your CSS skills. Land your dream job.

Better way to approach this Switch or Array scenario?

  • # February 14, 2013 at 10:59 pm

    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](http://codepen.io/ahabion/pen/Eqyoc “http://codepen.io/ahabion/pen/Eqyoc”)

    # February 15, 2013 at 5:08 am

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

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".