Home > OS >  Google chrome doesn't show the for loop in detail. I want to see every step
Google chrome doesn't show the for loop in detail. I want to see every step

Time:12-16

I know It is a silly question to ask but I'm starting new and trying to be a frontend developer. I was playing around with for loops and I wanted to know how chrome process it, so I try to view it on console section of chrome. It shows me that loop has processed 100 step but It doesn't show it in detail.

I'm attaching the for loop and the screenshot from console. Many thanks in advance.

For loop

enter image description here

Screenshot from the console

enter image description here

I want to see the results as this: starting from 1 and ending with 99.

CodePudding user response:

The (100) means that there are 100 duplicate log messages, so it just shows one of them along with the count.

If you want to see them all, open the console settings (the gear icon above the console output area) and uncheck "Group similar messages in console". Then you will see 100 lines with the message i.

If you intended to see the numbers from 0 to 100 you shouldn't put i in quotes. That makes it a string instead of a variable.

CodePudding user response:

 <script>
        // age output
        let age = parseInt(prompt("enter"));
        if (age < 10) {
            console.log("younger than 10 years");
        } else if (age === 10) {
            console.log("10 years old");
        } else if (age > 10 && age < 20) {
            console.log("the age is between 10 and 20");
        } else {
            console.log("above than 20 years");
        }

        // loop for 1 to 99
        for (let age = 0; age < 100; age  ) {

            console.log(age);
        }
    </script>
  • Related