Skip to content
Advertisement

Why my loop stops executing only if I input false 2 times?

Why does my code execute like this? I want to break loop when user inputs “Q”, but it stops only when I input “Q” 2 times. Sometimes it doesn’t even stop after 2 “Q”s. It’s purely random.

code

JavaScript

exec output

JavaScript

Advertisement

Answer

No need to explicitly call init, calling Kasa() class will automatically call init

JavaScript

I would rather suggest to write the logic outside init in a seperate method

Advertisement