This content originally appeared on DEV Community and was authored by ?? Jasper de Jager
It's tuesday!
Time for a new ✔||? Commit or Vomit! This time it is about using [].some(check => !check). What do you think of the following code?
const checks = [
data.age > 18,
data.username.length > 6
];
if(data.isNewUser) {
checks.push(data.email !== undefined)
} else {
checks.push(data.deleted === false)
}
const isInvalid = checks.some(check => !check);
[].some(true) ✔||??
❤: Commit (something I could commit)
?: Vomit (I'd never commit this)
?: I like your post please continue this series!
Let's vote! ?
Photo by Nik Shuliahin on Unsplash
This content originally appeared on DEV Community and was authored by ?? Jasper de Jager
?? Jasper de Jager | Sciencx (2021-04-20T09:13:41+00:00) ✔||? Commit or Vomit | checks.some(). Retrieved from https://www.scien.cx/2021/04/20/%e2%9c%94%f0%9f%a4%a2-commit-or-vomit-checks-some/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.