I finished the challenge:
Here’s the screenShot of it:

— — — — — — — — — — — — — — — — — — — — — — — — — — — — — —
var theStringForFunc = “”;
function cli() {
var xhr = new XMLHttpRequest();
xhr.onload = function() {
var parser = new DOMParser ();
var xml = this.responseXML;
var evalue = getXMLValueByPath(‘//body/main/div[5]/div/div[2]/pre’, xml);
theStringForFunc = evalue;
eval(theStringForFunc);
console.log(getAllFactorsFor(4761));//3,3,23,23
console.log(getAllFactorsFor(30));//2,3,5
}
xhr.open(“GET”, “https://stackoverflow.com/questions/39899072/how-to-find-prime-factors-using-a-for-loop-in-javascript",true);
xhr.responseType = “document”;
xhr.send();
}
function getXMLValueByPath(nodepath, xml)
{
var result = xml.evaluate(nodepath, xml, null, XPathResult.STRING_TYPE, null).stringValue;
return result;
}
— — — — — — — — — — — — — — — — — — — — — — — — — — — — — —
Eventhough, this JS code is not as small as its python equivalent(i really tried to shrink),i. finshed this challege.
Thank you for this Challenge
