Skip to content

Instantly share code, notes, and snippets.

@pratikdevdas
Created December 26, 2021 13:00
Show Gist options
  • Save pratikdevdas/6ac4373a0b519de2d7c2b9e41583e40a to your computer and use it in GitHub Desktop.
Save pratikdevdas/6ac4373a0b519de2d7c2b9e41583e40a to your computer and use it in GitHub Desktop.
conditional rendering must remember
const addBlog = () => {
const newBlog = {
title: newTitle,
author: newAuthor,
url: newUrl,
}
if(newBlog.title.length<4)
{
return console.log('give longer value')
//stops if returned here
}
console.log('suceed')
// will log suceed without return statement
}
}
// shorthand
const addblog = () =>{
const newBlog = {
title: newTitle,
author: newAuthor,
url: newUrl,
}
const nameIsValid = newBlog.title.length<4
(!nameisValid) ? console.log('give longer value')
: console.log('suceed')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment