Always Comment Your Function..!!

Let’s dig in about the reason why we need to write the documentation as code in our repository.

A featured image
function setLocation(x, y) {
window.location.href = `${x}://${y}`;
}
window.location.href = `${x}://${y}`;
// args `x` with data type string, is a protocol
// args `y` with data type string, is a domain name
function setLocation(x, y) {
window.location.href = `${x}://${y}`;
}
/**
* A function that can be executed on address bar browser
* @param {string} x a host url
* @param {string} y a domain url
*/
function setLocation(x, y) {
window.location.href = `${x}://${y}`;
}
/**
* @param {object} fullName
* @param {string} fullName.firstName your first name
* @param {string} fullName.lastName your last name
*/
function overwriteData(fullName) {
return {
firstName: "Adib",
lastName: "Firman",
...fullName
};
}
const sum = (firstNum, secondNum) => firstNum + secondNum;

Conclusion

Put some comments on our function, depending on how it will be used are the given parameters very complex? or is it readable from the naming function and arguments created?

--

--

Currently doing some stuff on Web Platform and learn managing a team.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Adib Firman

Currently doing some stuff on Web Platform and learn managing a team.