我想知道如何在函数范围之外打印函数的返回值。我在网上进行了研究,发现下面的帖子bu只是给我了arr,但该帖子未定义。有人能指出我正确的方向吗? Console log not printing variable from function
//Creating an array of circles and fill them
Random random = new Random();
Circle circles[] = new Circle[20];
for (int i = 0; i < 20; i++) {
circles[i] = new Circle();
circles[i].setRadius(30);
}
//Adding circles to pane on random position and give them random collers
for (int i = 0; i < 20; i++) {
Random randon = new Random();
int randX = randon.nextInt((int) borderPane.getWidth() - 30);
int randY = randon.nextInt((int) borderPane.getHeight() - 30);
int rColor = 20 + randon.nextInt(235);
int gColor = 20 + randon.nextInt(235);
int bColor = 20 + randon.nextInt(235);
borderPane.getChildren().add(circles[i]);
circles[i].setCenterX(randX);
circles[i].setCenterY(randY);
circles[i].setFill(Color.rgb(rColor, gColor, bColor));
}
答案 0 :(得分:0)
您不应该自己单独调用multiplyAll
,而应该将其分配给这样的变量:
var product = multiplyAll([[60,60],[24,365]]);
如果只想打印出结果,您可以做的另一件事是将函数调用放在console.log
调用中,如下所示:
console.log("Print results of product" + multiplyAll([[60,60],[24,365]]));