node map has value

// Step 1: Create a Map in Node.js
const myMap = new Map();

// Step 2: Add key-value pairs to the Map
myMap.set('key1', 'value1');
myMap.set('key2', 'value2');
myMap.set('key3', 'value3');

// Step 3: Iterate over the Map using forEach
myMap.forEach((value, key) => {
    // Step 4: Log key and value for each entry in the Map
    console.log(`Key: ${key}, Value: ${value}`);
});

// Step 5: Check if the Map has a specific key
const keyToCheck = 'key2';
if (myMap.has(keyToCheck)) {
    // Step 6: Retrieve the value associated with the key
    const retrievedValue = myMap.get(keyToCheck);
    console.log(`Value for ${keyToCheck}: ${retrievedValue}`);
}

// Step 7: Delete a key-value pair from the Map
const keyToDelete = 'key1';
myMap.delete(keyToDelete);

// Step 8: Check the size of the Map
const mapSize = myMap.size;
console.log(`Size of the Map: ${mapSize}`);

// Step 9: Clear all entries from the Map
myMap.clear();

// Step 10: Check if the Map is empty after clearing
const isEmpty = myMap.size === 0;
console.log(`Is Map empty? ${isEmpty}`);