How to destroy spawn object?

Hii
I am new in unity and making a Vr model in unity software.
I have attached my coding , in my coding when I pressed vr button then cube object is spawn in postion . I want to destroy the spawn object . how to do , please help me how to destroy the spawn object with VR button

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;

public class Buttonblue : MonoBehaviour
{
public GameObject button;
public UnityEvent onPress;
public UnityEvent onRelease;
GameObject presser;
bool isPressed;

void Start()
{
    
}
private void OnTriggerEnter(Collider other)
{
    if(!isPressed)
    {
        button.transform.localPosition = new Vector3(5.29657f,003f,-13.75566f);
        presser = other.gameObject;
        onPress.Invoke();
        isPressed =true;
     }
}  
 private void OnTriggerExit(Collider other)
     {
        if(other.gameObject == presser)
        {
            button.transform.localPosition =new Vector3(5.29657f,0.015f,-13.75566f);
            onRelease.Invoke();
            isPressed =false;
            
        }
     }
 public void Cube()
        {
            GameObject Cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
            Cube.transform.localScale = new Vector3(2.0115f,0.05620522f,67.8194f);
            Cube.transform.localPosition =new Vector3 (0f,0.13f,33.84f);
        } 

}

To destroy the “Cube” object that you created with the VR button, you can add an additional method that will be called when the button is triggered. This method would destroy the “Cube” object. Here’s how you can modify your code:

Add a GameObject variable named “spawnedObject” to store the reference to the created object.

In the “Cube” method, save the reference of the created object in the “spawnedObject” variable.

Add a public method named “DestroySpawnedObject” that would destroy the created object and set “spawnedObject” to “null”.

Call the “DestroySpawnedObject” method when the VR button is triggered.

Here is the modified code with the above changes:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;

public class Buttonblue : MonoBehaviour {
public GameObject button;
public UnityEvent onPress;
public UnityEvent onRelease;
GameObject presser;
bool isPressed;
GameObject spawnedObject;

void Start() {

}

private void OnTriggerEnter(Collider other) {
    if (!isPressed) {
        button.transform.localPosition = new Vector3(5.29657f, 0.03f, -13.75566f);
        presser = other.gameObject;
        onPress.Invoke();
        isPressed = true;
    }
}

private void OnTriggerExit(Collider other) {
    if (other.gameObject == presser) {
        button.transform.localPosition = new Vector3(5.29657f, 0.015f, -13.75566f);
        onRelease.Invoke();
        isPressed = false;
    }
}

public void Cube() {
    GameObject Cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
    Cube.transform.localScale = new Vector3(2.0115f, 0.05620522f, 67.8194f);
    Cube.transform.localPosition = new Vector3(0f, 0.13f, 33.84f);
    spawnedObject = Cube;
}

public void DestroySpawnedObject() {
    if (spawnedObject != null) {
        Destroy(spawnedObject);
        spawnedObject = null;
    }
}

}