Could you explain in detail what means return?

The return statement says what the function outputs as value (and mark the end of the function). So not sure if this is clear example (and if this is what you mean), but consider the following example:

function returnSomething(){
  // do something
  return 5;
}

var x = returnSomething();

Basically the return statement determines what the value of x is. (5, in this case).

http://www.w3schools.com/jsref/jsref_return.asp

What mean : in return ?

Return means that the function returns some value to the caller and finishes it’s work. Since it “gives” a value to it’s caller, this value can be stored in variable.

I know what return means, I asking what means this double points between “Bet” and “Hold” - :

1 Like

Thank you very much. I guess I understand.

It’s like a condensed if-else block that you can use in an expression.

return count + (count > 0 ? " Bet" : " Hold");

is the same as

if (count > 0)
  return count + " Bet";
else
  return count + " Hold";
1 Like

Does anybody have a way to use the ternary only for that true part ? Say I don’t have an else statement but like the simplicity of the ternary operator over a whole if/else block ?

Can we do something like :

return true ? true : null;

I can’t think of anything other than just going for an if-statement:
if (true) return true;

It’s probably clearer this way compared to having a floating null in there.

1 Like

I had a lot of trouble with this exercise as well. The instructions are rather vague.