# Can a variable contain data from multiple functions at the same time?

**URL:** <https://forum.kirupa.com/t/can-a-variable-contain-data-from-multiple-functions-at-the-same-time/654222>\
**Category:** programming\
**Created:** [October 25, 2022, 12:19pm UTC](https://forum.kirupa.com/t/can-a-variable-contain-data-from-multiple-functions-at-the-same-time/654222 "2022-10-25T12:19:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![PaulAsaf2](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/paulasaf2/32/19187_2.png) [@PaulAsaf2](https://forum.kirupa.com/u/PaulAsaf2)\
**Post date:** [October 25, 2022, 12:19pm UTC](https://forum.kirupa.com/t/can-a-variable-contain-data-from-multiple-functions-at-the-same-time/654222/1 "2022-10-25T12:19:17Z")

</div>

Hi there! In the third chapter of the book JavaScript: Absolute Beginner’s Guide, an example is given where the variable myDistance first receives the result of calculations of the showDistance function, and then shows how the same variable myDistance receives a value from another function - getDistance. I didn’t really understand…can a variable contain data from multiple functions at the same time?

---

<div class="post-metadata">

**Author:** ![kirupa](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kirupa/32/11616_2.png) [@kirupa](https://forum.kirupa.com/u/kirupa)\
**Post date:** [October 26, 2022, 1:34am UTC](https://forum.kirupa.com/t/can-a-variable-contain-data-from-multiple-functions-at-the-same-time/654222/2 "2022-10-26T01:34:25Z")

</div>

Hi @PaulAsaf2 - welcome to the forums 🙂

The answer to your question is no. It will store the value of the last function that it called. If you have an example like this:

```auto
let foo = showDistance();
foo = getDistance();

```

The value of `foo` will be whatever `getDistance` returned. Whatever was returned by `showDistance` will no longer be remembered by the `foo` variable.

In the book, I’m essentially overwriting the original value with a new value, which is something you can do with variables declared using `let` or `var`,

Cheers,  
Kirupa 🏝
