jquery - How to make an if statement which will run a code based on "true" conditions in javascript -


it's hard explain problem title alone, since dont know myself want. post part of code, make shorter.
http://jsfiddle.net/b0ftlujj/
problem when trying display values of object properties.

myobject ={   property_1: myvalue_1,   property_2: myvalue_2, };  

my object can have "property_x" properties 5 of them, or none @ all. trying make if statement pseudo code:

for(var statname in myobject){   if(myobject has property called : 'property_1, property_2, property_3, property_4, property_5'.indexof(statname) != -1;)     //then display in html: '<img src="images/' + property_x(where x property 1/2/3/4 or 5) , display available properties in current object. can make work 5x if else statements check every property, since there cannot property_1 , property_3/4/5 if "2" missing. looking better way display it.   } }  

i hope can understand question. if not @ least jsfiddle nice :) link resources if else statements can learn how make them better(unlike jsfiddle code).
can provide :)
please note, prefer javascript, want learn jquery guess option, if show me answer jquery ask link documentation can read , understand code about. again.

not sure understand second part of question, here's simplified version of fiddle:

var randomnumber = math.floor((math.random() * 100) + 1);  if (dropitem.itemtype === "weapon") {    dropitem["materiaslot_1"] = 'empty';    if (randomnumber >= 40) dropitem["materiaslot_2"] = 'empty';    if (randomnumber >= 60) dropitem["materiaslot_3"] = 'empty';    if (randomnumber >= 80) dropitem["materiaslot_4"] = 'empty';    if (randomnumber >= 95) dropitem["materiaslot_5"] = 'empty';  };


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -