---
title: "Comment by Bento on \"Javascript Clean Code Tips & Good Practices\" | Hashnode"
description: "Thank you for the article. It seems like point 14 example doesn&#39;t follow the rules you talk about yourself. For example: function isPercentage ( val ) { ..."
url: "https://hashnode.com/posts/javascript-clean-code-tips-and-good-practices/612221e8a5d08237f40e1bca/comment/61238b38b115357df05f1984"
---

[Discussion](https://hashnode.com/posts/javascript-clean-code-tips-and-good-practices/612221e8a5d08237f40e1bca)

Comment [Javascript Clean Code Tips & Good Practices](https://hashnode.com/posts/javascript-clean-code-tips-and-good-practices/612221e8a5d08237f40e1bca)

[Bento](https://hashnode.com/@bento)

[Aug 23, 2021](https://hashnode.com/posts/javascript-clean-code-tips-and-good-practices/612221e8a5d08237f40e1bca/comment/61238b38b115357df05f1984)

Thank you for the article.

It seems like point 14 example doesn't follow the rules you talk about yourself. For example:

```
function isPercentage(val) {
 ...
}
```

This function should be named `checkIfInRange` or something that makes it more obvious that it is a function. To me as a developer something that is prefixed with `is`, will most likely be a `boolean`. In my opinion a better approach at this is:

```
function checkIfInRange(amount) {
  return (amount >= 0 && amount <= 100);
}

const isInRange = checkIfInRange(78);
console.log(isInRange); // true
```

[Apoorv Tyagi](https://hashnode.com/@apoorvtyagi)

[Aug 23, 2021](https://hashnode.com/posts/javascript-clean-code-tips-and-good-practices/612221e8a5d08237f40e1bca/comment/61238b38b115357df05f1984#reply-61239d9db115357df05f1cc1)

Thanks [Bento](https://hashnode.com/@bento) :)

`To me as a developer something that is prefixed with is, will most likely be a boolean` - Here, isPercentage() is a boolean function which tells whether a value is a percentage or not. For that, we are checking if val is in the range of 0-100 & it is the only validation we doing here.

In case we would have more validations and function starts to get bigger then we can create separate functions for that with the names like the one which you made `checkInRange()` and others like `isNegative()` etc.

[Bento](https://hashnode.com/@bento)

[Aug 23, 2021](https://hashnode.com/posts/javascript-clean-code-tips-and-good-practices/612221e8a5d08237f40e1bca/comment/61238b38b115357df05f1984#reply-6123c44d663d427e19ff86d3)

[Apoorv Tyagi](https://hashnode.com/@apoorvtyagi)

Indeed `isPercentage()` is but `isPercentage` isn't. In my opinion functions should be named to the actions they are taking and not what their return values will be, for example `getUser, checkNaming`, otherwise if you name the function isPercentage what will you name the return value?

```
function isPercentage(val) {
  var isInRange = (val >= 0 && val <= 100);
  return isInRange;
} 

const ??? = isPercentage(9);
```

So the naming for the function above is bad 👎 as it implies a boolean type but is a function.

Also, that function does not check if a value is a percentage, I'd expect that if a function is called isPercentage it would test if a string contains a value like `%` or a logic around it.

Naming a function like this will lead to confusion and the point of the article is to leave things clean and with good practices, you advocate good practices and explain them in other points but this is not one of them.

There's no such thing as _boolean functions_, it's just a `function` that returns a `boolean`.

`typeof(isPercentage)` is `function` and not `boolean`.

[Dylan Watson](https://hashnode.com/@dylanwatsonsoftware)

[Aug 25, 2021](https://hashnode.com/posts/javascript-clean-code-tips-and-good-practices/612221e8a5d08237f40e1bca/comment/61238b38b115357df05f1984#reply-6126ce7971cb04254f06c1ea)

[Bento](https://hashnode.com/@bento) it actually took me a little while to get what you were saying... But it makes some sense. I've never thought about it like that before. I definitely have had that issue where I end up wanting to name the variable the same as the function.

Also... Great article [Apoorv Tyagi](https://hashnode.com/@apoorvtyagi)!

[Apoorv Tyagi](https://hashnode.com/@apoorvtyagi)

[Aug 26, 2021](https://hashnode.com/posts/javascript-clean-code-tips-and-good-practices/612221e8a5d08237f40e1bca/comment/61238b38b115357df05f1984#reply-6127b45571cb04254f06d9e0)

Thanks [Dylan Watson](https://hashnode.com/@dylanwatsonsoftware)
