In Python, a function must be defined before it's used. But that's not so in JavaScript! As long as a function is defined somewhere in the file, it can be called even before the definition.
console.log(getLabel(3));
// prints 'awful'
function getLabel(numStars) {
if (numStars > 7) {
return "great";
} else if (numStars > 3) {
return "okay";
} else {
return "awful";
}
}
This works because JavaScript "hoists" the function declaration to the top of the file before the code is executed.