The Lodge is members-only design/dev videos and Office Hours.

Next Office Hours Session: "Programming Fundamentals" Dec 02 - 2:00 PM Eastern

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: []( “”)

    # February 15, 2013 at 5:08 am

    This reply has been reported for inappropriate content.

    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.

There's a whole bunch of content on CSS-Tricks.

Search for Stuff   •   Browse the Archives

Get the Newsletter ... or get the RSS feed