My question isn’t so much about coding itself but more about effective communication in a developer environment and understanding core concepts.
While studying JavaScript on another platform, I encountered a coding challenge with a step that read:
Create a function functionName that takes the average value of both parameters and then logs it to the console.
I tackled it, but for the sake of thoroughness I reviewed the solution provided. The person offered this code:
const functionName = function (parameter1, parameter2) {
// ... (code for the function) ...
};
Here’s my nitpicky question:
The code above isn’t a function named functionName but rather a const named functionName with a function expression assigned to it, right?
If I tell someone, “Create a function functionName,” it seems to imply that it can’t be a function expression or arrow function — since both are anonymous — but must be a function declaration, like this:
function functionName (parameter1, parameter2) {
// ... (code for the function) ...
}
It’s a bit pedantic, I know, but I’d appreciate any insights on this to double-check if I’m understanding these concepts correctly. My hunch is that precise instructions matter, especially since certain scenarios may require a function to be coded as a declaration rather than an expression or arrow function.