I am a beginner in javascript, and I don't know why my variable is undefine.
Here is my code:
function createBlockMap(data) {
//console.log(data.X + " " + data.Y + " " + data.food);
    var makeOverOut = function (mesh) {
        mesh.actionManager = new BABYLON.ActionManager(scene);
        mesh.actionManager.registerAction(new BABYLON.SetValueAction(BABYLON.ActionManager.OnPointerOverTrigger, mesh.material, "diffuseTexture", mesh.material.diffuseTexture = new BABYLON.Texture("../assets/GrassLight.jpg", scene)));
        mesh.actionManager.registerAction(new BABYLON.SetValueAction(BABYLON.ActionManager.OnPointerOutTrigger, mesh.material, "diffuseTexture", mesh.material.diffuseTexture = new BABYLON.Texture("../assets/Grass.jpg", scene)));
        mesh.actionManager.registerAction(new BABYLON.InterpolateValueAction(BABYLON.ActionManager.OnPointerOutTrigger, mesh, "scaling", new BABYLON.Vector3(1, 1, 1), 150));
        mesh.actionManager.registerAction(new BABYLON.InterpolateValueAction(BABYLON.ActionManager.OnPointerOverTrigger, mesh, "scaling", new BABYLON.Vector3(1.1, 1.1, 1.1), 150));
        mesh.actionManager.registerAction(new BABYLON.SetValueAction(BABYLON.ActionManager.OnPickTrigger, button2Rect, "levelVisible", true))
        .then(new BABYLON.SetValueAction(BABYLON.ActionManager.OnPickTrigger, button2Rect, "levelVisible", false));
    }
    var blockInfo = function (data) {
        box = new BABYLON.Mesh.CreateBox("crate", 1, scene);
        box.material = new BABYLON.StandardMaterial("Mat", scene);
        box.material.diffuseTexture = new BABYLON.Texture("../assets/Grass.jpg", scene);
        box.position.z = data.Y;
        box.position.x = data.X;
        box.position.y = 3;
        ownfood = data.food;
        console.log(this.ownfood);
        console.log(data.food);
        Linemate = data.Linemate;
        Deraumere = data.Deraumere;
        Sibur = data.Sibur;
        Mendiane = data.Mendiane;
        Phiras = data.Phiras;
        Thystame = data.Thystame;
        makeOverOut(box);
    }
    var button2Rect = new BABYLON.Rectangle2D(
        {   parent: canvas, id: "buttonClickRes", x: 250, y: 250, width: 100, height: 40, fill: "#4040C0FF",
        roundRadius: 10, isVisible: false,
        children:
        [
            new BABYLON.Text2D("Food: " + blockInfo.ownfood, { id: "clickmeRes", marginAlignment: "h:center, v:center" })
        ]
    });
    if (map[data.Y] == null)
    {
        map[data.Y] = new Array();
    }
    map[data.Y][data.X] = blockInfo(data);}
Why blockInfo.ownfood is undefine on "button2Rect" even if I assign "data.food" on the blockInfo function and how can I solve this.
Thanks
 
    