Answers for "make shorter if statements with objects"

6

shorthand if statment in js

isLoggedIn ? "Logout" : "Login";
Posted by: Guest on April-19-2020
0

make shorter if statements with objects

var name_map = {
        "#first": "First Name",
        "#middle": "Middle Name",
        "#last": "Last Name"
}

if (Object.keys(check_map).every(selector => $(selector).val())) { 
	  // Yes, they all have non-blank values
} else {
	// No, at least one of them has a blank value (or didn't exist at all)
}
Posted by: Guest on June-15-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language