Created
December 26, 2021 13:00
-
-
Save pratikdevdas/6ac4373a0b519de2d7c2b9e41583e40a to your computer and use it in GitHub Desktop.
conditional rendering must remember
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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