From 3f42b3eab88aeb0be20b380a0af480ec016ef805 Mon Sep 17 00:00:00 2001 From: "Laetitia (O-01-67)" <68935009+O-01-67@users.noreply.github.com> Date: Tue, 20 Dec 2022 10:00:52 -0500 Subject: [PATCH] i hate moving code it's so tedious having to delete the code and paste it into another file and update the github on both steps --- mods/code_library.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/mods/code_library.js b/mods/code_library.js index 7cf9402d..8aa6305f 100644 --- a/mods/code_library.js +++ b/mods/code_library.js @@ -108,6 +108,19 @@ return tempArray; }; + function tryJoin(stringOrArray,joiner) { + //console.log(`tryJoin: ${stringOrArray}`); + if(typeof(stringOrArray) === "string") { + //console.log("tryJoin: String"); + return stringOrArray; + } else if(Array.isArray(stringOrArray)) { + //console.log("tryJoin: Array"); + return stringOrArray.join(joiner); + } else { + throw new TypeError(`Unexpected type: ${typeof(stringOrArray)}`); + }; + }; + //Checks //Element exists in the elements object