JavaScriptQuestion 23 of 36
Difference between function and method?
Answer out loud or in your head first, then compare.
Answer
Function:
JavaScript
function add(a, b) {
return a + b;
}Method:
JavaScript
const calculator = {
add(a, b) {
return a + b;
}
};A method is a function that belongs to an object.
How did it go? Be honest — “Not yet” puts the question on your review list.