Here is the code what i am trying out
My only question why my code is not assigning the value of y in projectAreaContextId? Edit 1: i have corrected something
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
        myFunction(this);
    }
};
var random =widgetLink+"/ccm/rpt/repository/workitem?fields=workitem   /projectArea/*";
xhttp.open("GET", random , true);
xhttp.send();
function myFunction(xml) {
    myHashMap = {};
    var xmlDoc = xml.responseXML;
    x = xmlDoc.getElementsByTagName('contextId');
    a = xmlDoc.getElementsByTagName('name');
    for(i=0;i<a.length;i++)
    {
        y = x[i].childNodes[0].nodeValue;
        if((a[i].childNodes[0].nodeValue)===(actualPA)){
            console.log("uuid for pa"+y);
        }
    }
}
if (parentLink.includes(templink)) {
    projectAreaContextId = y.toString(); 
    console.log(projectAreaContextId);
}
 
    