Skip to content

re: There's no "else if" in JS VIEW POST

re: 99% of businesses ???????? If you consider that COBOL has been back ... If you consider that many banks prefer continue with old COBOL (not the ne...

Legacy is legacy, there is no doubt (although COBOL was invented as a most imperative language ever.) I admit I exaggerated the percentage, though.

I've seen in your code of elixir-iteraptor some IF statement

I never said I am perfect. If I had 72hrs/day I would be always writing the good code avoiding ifs. This is a solid settlement: I use ifs to save some time, while I still expressly understand I could do better.

I'm intrigued by what you said about if-statements. I'm curious to know how you would write the following callback function.

someRequest(URL, (err, result) => {
    if (err) {
    } else console.log(result);

I'm still a novice so it's difficult for me to imagine doing some things without if-statements. I would appreciate it if you could show meπŸ˜…πŸ™‚.

You could use something like promises.

.then(result => console.log(result))
.catch(err => console.log(err));

Ooh. That's right. Forgot promises could do thatπŸ˜…. Thanks 😊

code of conduct - report abuse