DEV Community

Discussion on: You may not need the if-else statement😎

Collapse
 
jawwad22 profile image
jawwad22

Hi, I try to use work in my app, but i am unable to implement this


for (let index = 0; index < 10; index++) {
        (a==a && b == b) && (return "hello")
    }

give error on return and if i removed return, noting return

Collapse
 
prateekarora profile image
Prateek Arora

Hey Jawwad,
Loved to hear that at least you show your interest into this.
But It's not an execution block when the pointer came to check the condition && or || and seeking for true or false and to find boolean they run those instruction. Where we can't return anything.
But if-else consistent execution block we can able to execute our instruction.

Hope you understand or for more DM on Twitter @prateekCodes
Love to answer your query:)