I am having problems with one script were I cant call my functions

(function(global){
var Module = global = {};
pc.math.noise.generateNoiseMap = function(mapWidth, MapHeight, scale) {
let noiseMap = [mapWidth, mapHeight];
if(scale <= 0){
scale = 0.0001;
}
for(y = 0; y < mapHeight; y++) {
for(x = 0; x < mapWidth; y++){
let sampleX = x / scale;
let sampleY = y / scale;
let perlinValue = pc.math.perlin2(sampleX, sampleY);
noiseMap [x,y] = perlinValue;
}
}
return noiseMap;
};
})();

but when I type pc.math.noise.generateNoiseMap it doesn’t show up as a function. I have another script like this and it works just fine. pc.math.perlin2 is from this other script

The script depends on pc.math.noise which is maybe not yet initialized, to make it independent from the script order, it could assign that object itself:

if (!pc.math.noise) {
pc.math.noise = {}
}

Then the rest of the script looks like adopted from C# or something, this doesn’t work: