I wrote a very simple addition function. The first code was written with the traditional function. But I want to write the same code with arrow function, but a red error appears under the arrow sign and when I want to see the result with console.log, I get a meaningless error. Why? and How do I write this function in its simplest form with the arrow function? Thanks!!
// First way
function total(a, b) {
return a + b;
}
console.log(total(5,2)); // Will print total "7"
// Second way
total(a, b) => {
return a + b; // **Will I get an error when I print console.log(total(5,2))! Why?**
}