javascript - JS, making a symbol into a parameter -


so, trying make following js function:

something.html(parseint(something.html()) + 1);  function rh_count(a,b){     return a.html(parseint(a.html()) b 1);   }; 

how make symbol (plus sign "+") function parameter?

you can add 1 or -1 param, , add two, 1 multiplied param. so:

function rh_count(a,b){     return a.html(parseint(a.html()) + 1 * b);   };  rh_count( <param>, 1 ); rh_count( <param>, -1 ); 

as wish, can make variable out of numbers, so:

var plus = 1, minus = -1;  function rh_count(a,b){     return a.html(parseint(a.html()) + 1 * b);   };  rh_count( <param>, plus ); rh_count( <param>, minus ); 

Comments