1

so, i have the following js:

function RHL(a,b,c)
{
  return rx.removeClass(a).addClass(b); 
  return rhpfc.html(parseInt( rhpfc.html() ) -1 );      
} 

I am having a bit of difficult time with the formatting and syntax.

How do I combine both lines under one return. Also, I want to have two options: -1 or +1. So, I thought I would make - or + as c.

what kind of bracket do I need? (ie. 'c'1)

5
  • JavaScript functions can only return one value. Try combining the two statements into an array or the like. Commented Jan 14, 2016 at 0:30
  • I see. that was the issue. Thank you for the clarification. Commented Jan 14, 2016 at 0:30
  • I don't think that the return statement is necessary at all with what you are trying to do. Commented Jan 14, 2016 at 0:31
  • Without the return, I am getting undefined error in this case. :P Commented Jan 14, 2016 at 0:32
  • Instead of passing + or - try passing 1 or -1 as c Commented Jan 14, 2016 at 0:34

1 Answer 1

3
function RHL(a,b,c){
  return [
    rx.removeClass(a).addClass(b), 
    rhpfc.html(parseInt( rhpfc.html() ) -1 )
   ];      
} 

then you will need to use the index 0 or 1 to use the return value..

var rx = RHL(a,b,c)[0];

or

var rhpfc = RHL(a,b,c)[1];
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.