Question: function concatenator ( a , b ) { / / concatenator takes two arguments named a and b: / / * If a and b

function concatenator(a,b){
// concatenator takes two arguments named a and b:
//* If a and b are strings, return them concatenated
//* If a and b are numbers, return their sum
// Other conditions that must be met:
//* Both a and b must be of the same type. If they are not the same type, return the string "a and b must be of the same type"
//* a and b can be either numbers or strings. If they are not, return "a and b must be numbers or strings"
// Hint: The order of the conditions in the pseudo-code above and in the actual code is not necessarily the same
// Hint: It's advised to deal with the other conditions first, like arguments being of the wrong type.
//

Step by Step Solution

3.50 Rating (160 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

function concatenatora b Check if a and b are of the same type if type... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!