Help with JS, higher order functions

What is the name of this type of function express in three parts and using a ?

return checkA === checkB ? func(val) : ‘inconsistent results’;

That’s a ternary expression, which is just a condensed if…else block. It then returns the result of func(val) is checkA equals checkB, otherwise, it’ll return "inconsistent results".

1 Like

When used with return the whole thing is called a ternary statement. What @codeneutrino describes is a ternary expression, so it fulfills the value requirement of return.

return value;

which can translate to,

return expression;

Bottom line, the ternary is used, but we also need to be aware of what constitutes a statement and what constitutes an expression. Stay on this line of study while sorting these concepts out. Don’t rush ahead until all of this stuff is crystal clear in your mind.

1 Like

Thanks a lot guys for the support!