Skip to content

Commit

Permalink
Completed ShortLongShort
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinctofel committed Apr 9, 2022
1 parent 08b3cf8 commit 7298b9a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions ShortLongShort.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Write a function that takes two strings as arguments, determines the length
// of the two strings, and then returns the result of concatenating the shorter
// string, the longer string, and the shorter string once again. You may assume
// that the strings are of different lengths.

const shortLongShort = (str1, str2) => {
return (str1.length < str2.length ? str1 + str2 + str1 : str2 + str1 + str2);
};

console.log(shortLongShort('abc', 'defgh'));
console.log(shortLongShort('abcde', 'fgh'));
console.log(shortLongShort('', 'xyz'));

0 comments on commit 7298b9a

Please sign in to comment.