Quick actions

cmd+k|ctrl+k

Navigation

Languages

function

Snippet info

Language

JavaScript

Visibility

public

Author

hltse59

Created

2025-12-09T02:40:55.60852Z

Updated

2025-12-09T06:56:21.033386Z

console.log(calculator(10, 20, "add"))

function calculator(a, b, operation) {
 switch(operation) {
 case "add":
 case "+":
    return a + b;
 case "minus":
 case '-':
    return a - b;
 case "times":
 case '*':
    return a * b;
 case "divided":
 case '/':
    return a / b;
 default:
 return "無效的操作";
 }
}
INFO