lincwell / frontend-coding-guideline

Linc'well Frontend Coding Rules
1 stars 0 forks source link

early return を使う #25

Closed tyankatsu0105 closed 9 months ago

tyankatsu0105 commented 1 year ago

概要

SSIA

なぜ足したいのか

const earlyReturn =  (name:string) => {
    if (name) {
        if (name === "James") {
            return name
        } else {
            return "execpt James"
        }
    } else {
        return 'no names'
    } 
}
const earlyReturn =  (name:string) => {
    if (!name) return 'no names'
    if (name === "James") {
        return name
    }
    return 'except James'
}