# Calling a function within a function

**URL:** <https://discourse.nodered.org/t/calling-a-function-within-a-function/10439>\
**Category:** General\
**Created:** [22 April 2019 20:46 UTC](https://discourse.nodered.org/t/calling-a-function-within-a-function/10439 "2019-04-22T20:46:29Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![ftricamo](https://avatars.discourse-cdn.com/v4/letter/f/e79b87/32.png) [@ftricamo](https://discourse.nodered.org/u/ftricamo)\
**Post date:** [23 April 2019 00:56 UTC](https://discourse.nodered.org/t/calling-a-function-within-a-function/10439/7 "2019-04-23T00:56:19Z")

</div>

This did it,

I can work with this

> [@Use function multiple times](https://discourse.nodered.org/t/use-function-multiple-times/7280/3):
>
> One approach would be to use the global.set() with the memory module. store your function in a global variable: global.set('sum', function(a, b) { return a + b; }, 'memoryOnly'); use your function: msg.payload = global.get('sum', 'memoryOnly')(2, 3); return msg; Note: you need this setting in the settings.js: contextStorage: { default: { module:"localfilesystem" }, memoryOnly: { module: "memory" } }, Flow: [{"id":"4ac…

---

_[View the full topic](https://discourse.nodered.org/t/calling-a-function-within-a-function/10439)._
