diff --git a/pxt.json b/pxt.json index 65230d6..c9c044c 100644 --- a/pxt.json +++ b/pxt.json @@ -7,6 +7,7 @@ }, "files": [ "src/main.ts", + "src/utility/invertObject.ts", "README.md", "LICENSE.md" ], diff --git a/src/main.ts b/src/main.ts index e32b0f5..5520e0e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -35,18 +35,6 @@ const morseCode = { let stringToSend = ""; let currentlyTypingString = ""; -const invertObject = (object: {[key: string]: string}) => { - const newObject: {[key: string]: string} = {}; - - for (const key of Object.keys(object)) { - const value = object[key]; - - newObject[value] = key; - } - - return newObject; -} - const invertedMorseCode = invertObject(morseCode); const getMatch = () => { diff --git a/src/utility/invertObject.ts b/src/utility/invertObject.ts new file mode 100644 index 0000000..4eae366 --- /dev/null +++ b/src/utility/invertObject.ts @@ -0,0 +1,11 @@ +const invertObject = (object: {[key: string]: string}) => { + const newObject: {[key: string]: string} = {}; + + for (const key of Object.keys(object)) { + const value = object[key]; + + newObject[value] = key; + } + + return newObject; +}