4 ms·
Is anyone else bothered by the code at the beginning of this article? Simply returning the expression would have had the same effect, ie: function getDevJo
by zengid 10y ago
Is anyone else bothered by the code at the beginning of this article? Simply returning the expression would have had the same effect, ie:
function getDevJob(studying, hardWork, luck){
return studying && hardWork && luck;
}
I know that it might not make the code readable to novice javaScripters, but it bothers me anyway..
- Humdeee 10y agoI'm more bothered because it's becoming "so clever" to put everyday life activities into a function. I saw code written in chalk on a sidewalk billboard at the door of a coffee shop yesterday. No, I will not reciprocate that cringe and verbally call a function to order my coffee because the barista learned Hello World the previous night.
- tnecniv 10y agoBecoming? It's been this way since I first started hanging out in internet tech circles (eight years, longer I'm sure).
- bhntr3 10y agoYes. It's a rhetorical device. And some could argue that code is also a rhetorical device. But the only argument an if else block that returns true or false based on a boolean makes is "I'm not very good at this"
- Chromozon 10y agoI immediately picked up on this, too. From the code I've seen, novice programmers tend to do this a lot more often than someone who has been programming for a while. On a similar note, another thing novice programmers do often is rewrite min and max using if-else.
- badthingfactory 10y agoThat's not even the biggest problem with this method. The name is totally wrong.