How about this answer?
- For example, when
=DOUBLE(A1)
is used, the value of input
of DOUBLE(input)
is retrieved as a number or a string (in your case, it's a number.).
- For example, when
=DOUBLE(A1:B1)
is used, the values of input
of DOUBLE(input)
are retrieved as 2 dimensional array.
It is required to calculate after it confirmed whether input
is array. The modification which reflected above is as follows.
From :
return input * 2;
To :
return Array.isArray(input) ? input.map(function(e){return e.map(function(f){return f * 2})}) : input * 2;
Note :
When the above modified sample is written using "if" and "for loop", it becomes as follows.
if (Array.isArray(input)) {
var result = [];
for (var i = 0; i < input.length; i++) {
var temp = [];
for (var j = 0; j < input[i].length; j++) {
temp.push(input[i][j] * 2);
}
result.push(temp);
}
return result;
} else {
return input * 2;
}
If I misunderstand your question, I'm sorry.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…