āœ”||šŸ¤¢ Commit or Vomit | checks.some()

jmdejager

šŸ¤šŸ„‡ Jasper de Jager

Posted on April 20, 2021

āœ”||šŸ¤¢ Commit or Vomit | checks.some()

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);
Enter fullscreen mode Exit fullscreen mode

[].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

šŸ’– šŸ’Ŗ šŸ™… šŸš©
jmdejager
šŸ¤šŸ„‡ 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.

Related

JavaScript Array checks
javascript JavaScript Array checks

February 23, 2024

Queuing Rest Apis using JavaScript
javascript Queuing Rest Apis using JavaScript

April 10, 2023

What is the first thing everyone do?
javascript What is the first thing everyone do?

July 24, 2022

#9 Guess the output ???
javascript #9 Guess the output ???

March 24, 2022