js-code-to-svg-flowchart icon indicating copy to clipboard operation
js-code-to-svg-flowchart copied to clipboard

Nested if-statement problem

Open RiccardoGrigoletto opened this issue 7 years ago • 5 comments

capture

RiccardoGrigoletto avatar Feb 01 '18 10:02 RiccardoGrigoletto

Hi, nice catch! Can you pleae provide which caused that? So it will be able to debug it through.

Bogdan-Lyashenko avatar Feb 01 '18 10:02 Bogdan-Lyashenko

Provide code :)

Bogdan-Lyashenko avatar Feb 01 '18 10:02 Bogdan-Lyashenko

Hello bodgan .

The code is: if ( $(document).width() >= 992) { type = 'desktop'; } else if ( $(document).width() >= 768) { type = 'tablet'; } else { type = 'mobile'; }

Furthermore, I noticed that there are green boxes with "$(document)" as content.

RiccardoGrigoletto avatar Feb 01 '18 10:02 RiccardoGrigoletto

@RiccardoGrigoletto , thanks, I'll have a look. But looks like it's an issue with $(document).width() so actually methodCall().anotherMethodCall() structure fails, if you write your code in a way as below, it works fine image

Actually, caching jQuery object to variable instead of creating it each time is better way of doing this 🙂

Bogdan-Lyashenko avatar Feb 01 '18 15:02 Bogdan-Lyashenko

Here we are 👍 thank you :)

RiccardoGrigoletto avatar Feb 01 '18 15:02 RiccardoGrigoletto