Skip to content

Commit

Permalink
Fix readability
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgenherje committed Oct 16, 2023
1 parent 6c58497 commit 6149e28
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
* Example: ["a", "b", "c"] -> "a, b and c"
*/
export function makeDisplayStringFromStringArray(stringArray: string[]): string {
return stringArray.length === 0
? ""
: stringArray.length === 1
? stringArray[0]
: stringArray.slice(0, -1).join(", ") + " and " + stringArray[stringArray.length - 1];
if (stringArray.length === 0) return "";
if (stringArray.length === 1) return stringArray[0];

return stringArray.slice(0, -1).join(", ") + " and " + stringArray[stringArray.length - 1];
}

0 comments on commit 6149e28

Please sign in to comment.