4 ms·
Yea.. Can't get this to work.. Q: Given 2 strings, a and b, return a string of the form short+long+short, with the shorter string on the outside and the longer
by mattezell 13y ago
Yea.. Can't get this to work..
Q: Given 2 strings, a and b, return a string of the form short+long+short, with the shorter string on the outside and the longer string on the inside. The strings will not be the same length, but they may be empty (length0).
My Answer:
function solution(a, b){
if(typeof(undefined) == typeof(a))
a = "";
if(typeof(undefined) == typeof(b))
b = "";
if(a.length > b.length)
return b + a + b;
else
return a + b + a;
}
Result:
"Unknown Error"
Of course my solution doesn't account for a.length == b.length, but the question is somewhat nonsensical in that it states '...strings will not be the same length, but they may be empty...' (2 empty strings would be the same length)...