Problem Statement
How do you correctly declare a function in JavaScript?
Explanation
In JavaScript, you declare a function using the keyword 'function', followed by a name and parentheses.
Inside the curly braces, you write the code that will run when the function is called.
Function declarations are hoisted, meaning you can call them even before they appear in the code.
Functions are used to group related logic into one reusable block.
This makes your program cleaner, easier to read, and more efficient to maintain.
Code Solution
SolutionRead Only
function greet() {
console.log('Hello World');
}
greet(); // Output: Hello World