const isString = (a, b, c) => {
if (((typeof a) == "string") && ((typeof b) == "string") && ((typeof c) == "string")) {
return "strings";
}
return "not strings";
}
为什么需要在参数后面添加
=>
才能使其工作?我通过试错的方式得到了这个测试问题的正确答案,但我不明白为什么没有=>
就无法工作。以下是说明:
创建一个名为“isString”的函数,它接受3个参数(x1、x2、x3)
检查每个参数是否为字符串,使用typeof。
如果每个参数都是字符串,则返回“strings”。
如果每个参数都不是字符串,则返回“not strings”。