why else statement runs even if the if statement being true?
Guys, why the else statement runs even if the if statement is true
i'd rather have something like this, but all you're missing is the type definition of connection there
7 Replies
why the else statement runs even if the if statement is truethere's 99.999999% chance the if statement is, in fact, not true and therefore the else statement runs there's 0.000001% chance the Javascript is wrong and you're right you also don't say uh...which if statement you're having trouble with, there's 2 of them
the one that checks if has a .jpg file in the folder
what can I do to solve it?
I am getting this message in the terminal
probably means that is running 2 times, one time it has a .jpg file and the 2nd time it has a file that is not a jpg
I'd start by checking if you are getting what you expect, console.log the name of the file or even just the extension, you'll see it running twice
if I just wanna check one file?
either make sure there's only one file in your directory
or don't use a loop to go through all the files, just pick the first one
okay, thanks 🙂