Apollo Vishwas
Sep 1, 2018 · 1 min read

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

    Apollo Vishwas

    Written by

    Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
    Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
    Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade