program mainly by viewing and reading parts of its source code, and they do so after implementation or as an interruption of implementation. At least one of the humans must not be the code's author. The humans performing the checking, excluding the author, are called "reviewers".
a Person and it could have weight and age const person = { personWeight: 100, personAge: 22 }; function setPersonWeight(person) { person.personWeight = 95; }
you have to, use object function updatePerson({name, weight, height, age}) {} updatePerson({ name: Chiqui Brenes, weight: 120, height: 60, age: 35 }) {}
use a flag to change what the function shoul do function createFile(name, temp) { if (temp) { fs.create(`./temp/${name}`); } else { fs.create(name); } }
✅ GOOD: By just read you can tell what is happening function isFormReady(form) { return form.updated && form.valid; } function shouldUpdateUser(form, user) { return isFormReady(form) && user.isLoggedIn; } if (shouldUpdateUser(form, user)) { updateUser(form.value); }
extra code will execute function getCarSize(car) { var result; if (car.width > 20) { result = 'SUV'; } else if (car.width > 10) { result = 'Sedan'; } else { result = 'Compact'; } return result; }
soon as we know the answer we return and stop the function function getCarSize(car) { if (car.width > 20) { return 'SUV'; } else if (car.width > 10) { return 'Sedan'; } return 'Compact'; }