Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

When i execute an if condition with the continue keyword in a while loop my browser dosen't open

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <head>LOOPS</head>
    <h1 id="string"></h1>
    <script language="javascript" type="text/javascript">
        let w = 10;
        while(w<=15){
            console.log(w)
            if(w==13){
                continue;
            }
            w++
        };
        
    </script>
</body>
</html>

So…As you can see here, Whenever i live reload this on my browser(firefox, chrome) It just keeps on reloading and dosen’t open but when i use the for loop and then use the if condition to skip a loop, It opens.
Please is there something i’m doing wrong, Because i just started learning javascript.

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

It’s because you’re creating an infinite loop. When you have the if statement and the continue keyword, it will skip to the next loop without incrementing w variable.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading