# Way to export a var

**URL:** <https://forum.makecode.com/t/way-to-export-a-var/31105>\
**Category:** Help\
**Created:** [October 10, 2024, 5:49pm UTC](https://forum.makecode.com/t/way-to-export-a-var/31105 "2024-10-10T17:49:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![yblacky](https://avatars.discourse-cdn.com/v4/letter/y/2acd7d/32.png) [@yblacky](https://forum.makecode.com/u/yblacky)\
**Post date:** [October 10, 2024, 5:49pm UTC](https://forum.makecode.com/t/way-to-export-a-var/31105/1 "2024-10-10T17:49:59Z")

</div>

Hey,

is there any way to export a var form the main.ts?  
I wanna store my highscores in a mongo database.  
How can I export var? I tried it with import functions, creating json, use global var.  
Nothing works with Makecode.

Can anyone help me in that case?

kind regards

---

<div class="post-metadata">

**Author:** ![a012](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/a012/32/24099_2.png) [@a012](https://forum.makecode.com/u/a012)\
**Post date:** [August 27, 2025, 5:41pm UTC](https://forum.makecode.com/t/way-to-export-a-var/31105/2 "2025-08-27T17:41:50Z")

</div>

Do export var score = 0. But there could have 1 problem, makecode’s typescript does not want you use var, so instead of use var, please use let, like this.

```auto
  export let score = 0

```
