It'd like to thank Jeffrey Way for this one.You can write cleaner code by simplifying your conditionals, and avoiding nesting them.Here's an example:```javascript var name = 'john'if (name) { return Hello, ${name} }if (!name) { return 'Hello, Stranger' }return 'Hello, Hacker' ```In this silly example, we check if a condition is true, if it is, we return (stop execution) right from inside the condition. Otherwise, continue down file.While a better example could have been thought of, I hope it paints a picture.
Submitted September 24, 2020 at 02:23PM by ACertainKindOfStupid
No comments:
Post a Comment