Statements define an action and are executed for their side effect.
Expressions produce a result without mutating state.
const getSalutation = function(hour) {
var salutation; // temp value
if (hour < 12) {
salutation = "Hey Anshul, Good Morning";
} else {
salutation = "Good Afternoon, Anshul"
}
return salutation; // mutated value
}
const getSalutation = (hour) => hour < 12 ? "Good Morning" : "Good Afternoon";
console.log(getSalutation(10)); // Hey Anshul, Good Morning
(This concept covers under functional programming using ES6)