ā||š¤¢ Commit or Vomit | checks.some()
š¤š„ Jasper de Jager
Posted on April 20, 2021
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 (I'd commit something like this)
š·: Vomit (we all know unicorns don't vomit)
š¦: Like your post please continue this series!
Let's vote! š
Photo by Nik Shuliahin on Unsplash
š šŖ š
š©
š¤š„ Jasper de Jager
Posted on April 20, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.