Example for Create a JavaScript Module
This example demonstrates the creation of the factorial_mod JavaScript module.
-
In the Connections panel, click the + icon in the JavaScript Modules node and then click Create.
-
In the MLE Module Name field, enter factorial_mod.
-
Click Apply.
The module appears under JavaScript Modules in the Connections panel.
-
In the Connections panel, expand JavaScript Modules, right-click factorial_mod and select Open.
The factorial_mod module pane appears.
-
Enter the following JavaScript function:
export function factorial(num) { if(num < 0) { return -1; } else if (num == 0) { return 1; } else { return(num * factorial(num-1)); } } -
Click the Compile icon to save the JavaScript code.
Note: Alternatively, you can save the code by using
ctr + sorcmd + s.
To import a module to an MLE environment, see Example for Create an MLE Environment.