[Solved] Uncaught TypeError: Cannot read property ‘Id’ of undefined

SFDC_Beginner Asks: Uncaught TypeError: Cannot read property ‘Id’ of undefined

Code:
var pl =[
    {
        "Id": "a0l5e000002mQ0QAAU",     
        "End_Date__c": null,
        "Name": "PL-028",
        "Start_Date__c": null
    },
    {
        "Id": "a0l5e000002mQ0aAAE",     
        "End_Date__c": "2021-11-30",
        "Name": "PL-003",
        "Start_Date__c": "2021-02-01"
    }
]

Code:
var pt = {
    "a0l5e000002mQ0QAAU": "<li>Monday</li>",
    "a0l5e000002mQ0aAAE": "<li>Thursday</li><li>Monday</li>"
}

Code:
pl.forEach(datainfo =>{ 
console.log(datainfo.Id)
var locId = datainfo.Id;
console.log(pt.locId ); // This line Throw the error
});

trying to get the pt value by passing Key

Uncaught TypeError: Cannot read property ‘Id’ of undefined at :3:25 at Array.forEach () at :1:4

when i console log as below it’s working. Can anyone help me what I am missing here

console.log(pt.a0l5e000002mQ0QAAU);

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.