Below are two functions which are both syntactically and semantically correct. The first one violates the famous software development principle, DRY (Don't Repeat Yourself) and the second function fixes it. The programming language used here is Javascript.
function validateObject(exampleObject){ //Violates DRY
const errorMessages = [];
if(!exampleObject["color"]){
errorMessages.push("Error! Please enter a value into the color field");
}