.length CodeWars test question

.length CodeWars test question

by BinaryAcid

HTML

<!------

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). 

Examples:
solution('Hello', 'hi') -> 'hiHellohi'
solution('hi', 'Hello') -> 'hiHellohi'

-->

JavaScript

function solution(a, b){
    
   if (a.length > b.length){
       return(b + a + b);        
   }
    else {
        return(a + b + a); 
    };

};

// document.write(solution('Hello', 'hi'));
document.write(solution('hi', 'Hello'));