I am trying to test some JavaScript on my local computer using the Chrome browser but Chrome will not load local resources (web page written in HTML and JavaScript) and ended up with an error message: Error Code: Result_Code_Hung. Does anyone know how to fix this loading problem? Or is there an easy workaround for this?
I tried to open the webpage with Safari, still not able to load the page.
The code is quite simple:
<body>
<h1> Test Loading</h1>
<script>
// calculate lcm of two natural numbers using do-while
function lcm (a, b){
if (a>b) {
let i=1;
do{
let lcNum= (a*i % b ===0) ? a*i: a*b ;
} while (i<=a);
return lcNum;
}
else if (b>a){
let i=1;
do{
let lcNum = (b*i % a ===0) ? b*i: a*b ;
} while (i<=b);
return lcNum;
}
}
console.log (lcm(4,6));
</script>
</body>