I need to implement this 'looking for girlfriend' logic. I wish to refactor, remove if / else statements and make this code more elegant. Thank you for any help.
`if($('#pretty').val()==='yes') {
if ( sheIsNotSmart()) {
forget();
} else {
keepTalking();
}
} else if($('#hard-working').val()==='yes') {
if (sheIsNotSmart()) {
forget();
} else {
dontRunAway();
}
} else {
if ($('#smart').is(':checked')) {
goOutTogether();
} else {
if (sheIsNotSmart()) {
runAwayQuickly();
} else {
keepLooking();
}
}
}`
I considered usage of Guard Clauses, but I'm not sure how to use it with if / else statements nested inside another if / else.
Aucun commentaire:
Enregistrer un commentaire