DEV Community

loading...

Discussion on: 5 ways to refactor if/else statements in JS functions

Collapse
vidhill profile image
David Hill • Edited

yup,
a solution would be to add a return before the console.warn then it would return undefined

if (str.length <= 3) return console.warn("your string should be at least 3 characters long and its length is", str.length) 
Enter fullscreen mode Exit fullscreen mode