Click here to Skip to main content
15,885,767 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Write a function that accepts two numbers as parameters, say ‘a’ and ‘b’. You need to write piece of code that will display the result of the following logic that has been specified to you as statement.

Logic statement: “Which of the parameters ‘a’ and ‘b’ is equal to 10”?
Posted
Comments
SoMad 14-Jun-12 6:29am    
You should do your own homework.

Soren Madsen

1 solution

While I think this is a homework question, I am going to help anyway!

JavaScript
function AB (a, b) {
     return a == 10 ? a : b == 10 ? b : null;
}


Assuming that only one or neither can equal 10.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900