using global variables in a javascript function code example
Example 1: create global variable inside function JavaScript
<script>
function foo() {
window.yourGlobalVariable = ...;
}
</script>
Example 2: global scope js
const color = 'blue'
const returnSkyColor = () => {
return color; // blue
};
console.log(returnSkyColor()); // blue