diff --git a/Minecraft Datapacking/When Two Macros are Faster than One.md b/Minecraft Datapacking/When Two Macros are Faster than One.md index 41e2ee0..a5c8196 100644 --- a/Minecraft Datapacking/When Two Macros are Faster than One.md +++ b/Minecraft Datapacking/When Two Macros are Faster than One.md @@ -6,7 +6,7 @@ While working on my Database datapack (still WIP), I knew I'd want to find # Scenario ## Dataset -The data is stored in a storage `#_macro.array`. Array is populated with a total of 500 entries, each having a `id` and `string` fields. +The data is stored in a storage `#_macro.array`. Array is populated with a total of 500 entries, each having `id` and `string` fields. ```json [ { @@ -21,8 +21,17 @@ The data is stored in a storage `#_macro.array`. Array is populated with a total ] ``` ## Constraints -The objective is to create an interface that receives a keyword, say `entry500`, and searches the array for an entry where the value of `string` matches the keyword. +The objective is to create an interface that receives a keyword, say `entry500`, and searches `#_macro.array` for an entry where the value of `string` matches the keyword. The keyword +In TypeScript, it would look something like this: +```ts +function searchArray(keyword: string) { + // logic + return theRelevantEntry +} + +searchArray('entry500') +``` # One Macro Macros allow us to reach into our array and pick out an entry that matching value in the `string` property. ```vb