问:
Efficient jQuery / JavaScript code to calculate average values in array of objects
I have a large JavaScript array of objects.  Each object contains temperature data for each month for many years.  I would like to find the average temperature data for each temperature-type for each month (there are actually 13 months in my data intentionally, so I want averages for 13 months).

In this jsfiddle, I have been playing with a very small subset of the data:

const array1 =
[
    {
        "Year": 1980,
        "Month": 0,
        "Tmin": null,
        "Tmean": 11.1914,
        "Tmax": null,
        "Td": 7.01668,
        "RHmean": 76.1544,
        "RHmax": 61.7298,
        "WBGTmin": 8.3829,
        "WBGTmean": 9.75617,
        "WBGTmax": null,
        "WBGTmaxSun": null,
        "UTCImin": 9.41549,
        "UTCImean": 11.5612,
        "UTCImax": null,
        "HImin": 8.03456,
        "HImean": 10.9305,
        "HImax": 14.2173
    },
    {
        "Year": 1980,
        "Month": 1,
        "Tmin": 11.931,
        "Tmean": 15.0778,
        "Tmax": 18.1379,
        "Td": 10.4667,
        "RHmean": 74.6458,
        "RHmax": 61.0794,
        "WBGTmin": 11.3724,
        "WBGTmean": 13.3417,
        "WBGTmax": 15.1419,
        "WBGTmaxSun": null,
        "UTCImin": 12.7629,
        "UTCImean": 15.5132,
        "UTCImax": 18.0733,
        "HImin": 11.5267,
        "HImean": 14.5908,
        "HImax": 17.6032
    },
    {
        "Year": 1980,
        "Month": 2,
        "Tmin": 10.8621,
        "Tmean": 14.3429,
        "Tmax": 18.1379,
        "Td": 9.55555,
        "RHmean": 73.3624,
        "RHmax": 58.0879,
        "WBGTmin": 10.4187,
        "WBGTmean": 12.5424,
        "WBGTmax": 14.8529,
        "WBGTmaxSun": null,
        "UTCImin": 11.663,
        "UTCImean": 14.6836,
        "UTCImax": 17.9196,
        "HImin": 10.3846,
        "HImean": 13.7489,
        "HImax": 17.5251
    },
    {
        "Year": 1980,
        "Month": 3,
        "Tmin": 11.069,
        "Tmean": 13.7278,
        "Tmax": 17.3103,
        "Td": 9.47038,
        "RHmean": 76.4473,
        "RHmax": 61.5543,
        "WBGTmin": 10.6146,
        "WBGTmean": 12.1394,
        "WBGTmax": 14.3354,
        "WBGTmaxSun": null,
        "UTCImin": 11.8356,
        "UTCImean": 14.1294,
        "UTCImax": 17.2034,
        "HImin": 10.57,
        "HImean": 13.1527,
        "HImax": 16.7052
    },
    {
        "Year": 1980,
        "Month": 4,
        "Tmin": 9.37931,
        "Tmean": 12.9241,
        "Tmax": 16.2759,
        "Td": 8.23148,
        "RHmean": 74.3115,
        "RHmax": 59.5891,
        "WBGTmin": 9.04303,
        "WBGTmean": 11.2406,
        "WBGTmax": 13.2503,
        "WBGTmaxSun": null,
        "UTCImin": 10.0756,
        "UTCImean": 13.2498,
        "UTCImax": 16.0892,
        "HImin": 8.72126,
        "HImean": 12.2128,
        "HImax": 15.5158
    },
    {
        "Year": 1980,
        "Month": 5,
        "Tmin": 8.07407,
        "Tmean": 10.6399,
        "Tmax": 14.4444,
        "Td": null,
        "RHmean": 76.2411,
        "RHmax": 60.2131,
        "WBGTmin": 7.57442,
        "WBGTmean": null,
        "WBGTmax": null,
        "WBGTmaxSun": null,
        "UTCImin": 8.70486,
        "UTCImean": null,
        "UTCImax": null,
        "HImin": 7.28312,
        "HImean": 9.75634,
        "HImax": 13.4938
    },
    {
        "Year": 1980,
        "Month": 7,
        "Tmin": 3.87097,
        "Tmean": 6.74194,
        "Tmax": 10.8065,
        "Td": 2.06452,
        "RHmean": 72.9362,
        "RHmax": 55.8054,
        "WBGTmin": 3.4279,
        "WBGTmean": 5.32629,
        "WBGTmax": 8.05513,
        "WBGTmaxSun": null,
        "UTCImin": 4.16556,
        "UTCImean": 6.88706,
        "UTCImax": 10.5796,
        "HImin": 2.5963,
        "HImean": 5.3759,
        "HImax": 9.3998
    },
    {
        "Year": 1980,
        "Month": 9,
        "Tmin": 6.23333,
        "Tmean": 8.97223,
        "Tmax": 11.6,
        "Td": 6.1037,
        "RHmean": 82.351,
        "RHmax": 69.5854,
        "WBGTmin": 6.31845,
        "WBGTmean": 8.00618,
        "WBGTmax": 9.71308,
        "WBGTmaxSun": null,
        "UTCImin": 6.92209,
        "UTCImean": 9.45113,
        "UTCImax": 11.7794,
        "HImin": 5.4295,
        "HImean": 8.07536,
        "HImax": 10.6328
    },
    {
        "Year": 1980,
        "Month": 10,
        "Tmin": 8.43333,
        "Tmean": 11.2852,
        "Tmax": 13.6667,
        "Td": 7.64815,
        "RHmean": 78.9403,
        "RHmax": 67.924,
        "WBGTmin": 8.29363,
        "WBGTmean": 10.0097,
        "WBGTmax": 11.5281,
        "WBGTmaxSun": null,
        "UTCImin": 9.19437,
        "UTCImean": 11.7425,
        "UTCImax": 13.8014,
        "HImin": 7.76501,
        "HImean": 10.5307,
        "HImax": 12.863
    },
    {
        "Year": 1981,
        "Month": 0,
        "Tmin": 8.54919,
        "Tmean": 11.5048,
        "Tmax": 14.5909,
        "Td": 7.70727,
        "RHmean": 79.2693,
        "RHmax": 65.5782,
        "WBGTmin": 8.81321,
        "WBGTmean": 10.2214,
        "WBGTmax": 12.1636,
        "WBGTmaxSun": 13.6712,
        "UTCImin": 9.60639,
        "UTCImean": 11.9768,
        "UTCImax": 14.6651,
        "HImin": 8.13911,
        "HImean": 11.1262,
        "HImax": 14.1329
    },
    {
        "Year": 1981,
        "Month": 1,
        "Tmin": 10.9355,
        "Tmean": 14.6649,
        "Tmax": 18.1935,
        "Td": 12.0968,
        "RHmean": 84.7151,
        "RHmax": 67.9045,
        "WBGTmin": 11.7611,
        "WBGTmean": 13.6596,
        "WBGTmax": 15.7362,
        "WBGTmaxSun": 18.1962,
        "UTCImin": 12.2129,
        "UTCImean": 15.4285,
        "UTCImax": 18.4067,
        "HImin": 10.6675,
        "HImean": 14.3994,
        "HImax": 17.8426
    },
    {
        "Year": 1981,
        "Month": 2,
        "Tmin": 12.0741,
        "Tmean": 14.5041,
        "Tmax": 17.5185,
        "Td": 12.251,
        "RHmean": 86.5258,
        "RHmax": 72.0491,
        "WBGTmin": 12.3043,
        "WBGTmean": 13.6124,
        "WBGTmax": 15.4261,
        "WBGTmaxSun": 17.545,
        "UTCImin": 13.2307,
        "UTCImean": 15.3403,
        "UTCImax": 17.8944,
        "HImin": 11.8769,
        "HImean": 14.2698,
        "HImax": 17.2081
    },
    {
        "Year": 1981,
        "Month": 3,
        "Tmin": 12.4074,
        "Tmean": 15.4167,
        "Tmax": 18.2593,
        "Td": 12.6071,
        "RHmean": 83.9611,
        "RHmax": 70.3348,
        "WBGTmin": 12.668,
        "WBGTmean": 14.3096,
        "WBGTmax": 15.9688,
        "WBGTmaxSun": 17.5687,
        "UTCImin": 13.5998,
        "UTCImean": 16.1949,
        "UTCImax": 18.5757,
        "HImin": 12.2142,
        "HImean": 15.2067,
        "HImax": 17.9783
    },
    {
        "Year": 1981,
        "Month": 4,
        "Tmin": 10,
        "Tmean": 12.7361,
        "Tmax": 15.8571,
        "Td": 9.64087,
        "RHmean": 82.5259,
        "RHmax": 67.9274,
        "WBGTmin": 10.0824,
        "WBGTmean": 11.6051,
        "WBGTmax": 13.5108,
        "WBGTmaxSun": 14.592,
        "UTCImin": 10.9405,
        "UTCImean": 13.3256,
        "UTCImax": 15.999,
        "HImin": 9.51275,
        "HImean": 12.2205,
        "HImax": 15.2729
    },
    {
        "Year": 1981,
        "Month": 5,
        "Tmin": 7.77419,
        "Tmean": 10.0627,
        "Tmax": 13.6129,
        "Td": 5.78494,
        "RHmean": 75.9491,
        "RHmax": 61.0582,
        "WBGTmin": 7.20217,
        "WBGTmean": 8.64684,
        "WBGTmax": 10.9509,
        "WBGTmaxSun": 11.6187,
        "UTCImin": 8.33175,
        "UTCImean": 10.4036,
        "UTCImax": 13.5211,
        "HImin": 6.89413,
        "HImean": 9.10776,
        "HImax": 12.6245
    },
    {
        "Year": 1981,
        "Month": 7,
        "Tmin": 4.9,
        "Tmean": 7.17407,
        "Tmax": 10.3667,
        "Td": 2.70556,
        "RHmean": 74.8556,
        "RHmax": 61.1368,
        "WBGTmin": 4.34986,
        "WBGTmean": 5.8641,
        "WBGTmax": 7.98966,
        "WBGTmaxSun": 8.615,
        "UTCImin": 5.264,
        "UTCImean": 7.39827,
        "UTCImax": 10.2977,
        "HImin": 3.69173,
        "HImean": 5.90138,
        "HImax": 9.05522
    },
    {
        "Year": 1981,
        "Month": 8,
        "Tmin": 4.45161,
        "Tmean": 7.92652,
        "Tmax": 11.871,
        "Td": 0.390681,
        "RHmean": 61.2032,
        "RHmax": 47.431,
        "WBGTmin": 3.40579,
        "WBGTmean": 5.77148,
        "WBGTmax": 8.40882,
        "WBGTmaxSun": 9.3788,
        "UTCImin": 4.54988,
        "UTCImean": 7.83204,
        "UTCImax": 11.4088,
        "HImin": 2.9492,
        "HImean": 6.37245,
        "HImax": 10.352
    },
    {
        "Year": 1981,
        "Month": 9,
        "Tmin": 4.2,
        "Tmean": 8.3537,
        "Tmax": 10.8667,
        "Td": 5.32407,
        "RHmean": 81.6902,
        "RHmax": 69.417,
        "WBGTmin": 5.1251,
        "WBGTmean": 7.35119,
        "WBGTmax": 9.0068,
        "WBGTmaxSun": 10.4248,
        "UTCImin": 4.87588,
        "UTCImean": 8.78665,
        "UTCImax": 11.0342,
        "HImin": 3.20796,
        "HImean": 7.37767,
        "HImax": 9.82164
    },
    {
        "Year": 1981,
        "Month": 10,
        "Tmin": 7.48387,
        "Tmean": 11.0681,
        "Tmax": 13.6774,
        "Td": 7.32616,
        "RHmean": 78.8369,
        "RHmax": 67.1361,
        "WBGTmin": 7.72401,
        "WBGTmean": 9.77781,
        "WBGTmax": 11.4299,
        "WBGTmaxSun": 13.2976,
        "UTCImin": 8.26469,
        "UTCImean": 11.5077,
        "UTCImax": 13.7745,
        "HImin": 6.74846,
        "HImean": 10.2892,
        "HImax": 12.8542
    },
    {
        "Year": 1981,
        "Month": 11,
        "Tmin": 10.1379,
        "Tmean": 13.2088,
        "Tmax": 16.0345,
        "Td": 9.78353,
        "RHmean": 80.1912,
        "RHmax": 67.215,
        "WBGTmin": 10.1662,
        "WBGTmean": 11.9142,
        "WBGTmax": 13.6553,
        "WBGTmaxSun": 15.937,
        "UTCImin": 11.0545,
        "UTCImean": 13.74,
        "UTCImax": 16.1454,
        "HImin": 9.6793,
        "HImean": 12.6796,
        "HImax": 15.4494
    },
    {
        "Year": 1981,
        "Month": 12,
        "Tmin": 12.3262,
        "Tmean": 14.8907,
        "Tmax": 17.3871,
        "Td": 11.7276,
        "RHmean": 81.5082,
        "RHmax": 69.7501,
        "WBGTmin": 12.1564,
        "WBGTmean": 13.6467,
        "WBGTmax": 15.1406,
        "WBGTmaxSun": 17.6416,
        "UTCImin": 13.3456,
        "UTCImean": 15.5432,
        "UTCImax": 17.6521,
        "HImin": 12.0881,
        "HImean": 14.5641,
        "HImax": 17.0036
    },
    {
        "Year": 1982,
        "Month": 0,
        "Tmin": 7.17557,
        "Tmean": 11.1063,
        "Tmax": 14.9062,
        "Td": 6.62961,
        "RHmean": 74.9441,
        "RHmax": 59.1579,
        "WBGTmin": 7.3061,
        "WBGTmean": 9.60836,
        "WBGTmax": 12.0246,
        "WBGTmaxSun": 13.5322,
        "UTCImin": 7.93259,
        "UTCImean": 11.4494,
        "UTCImax": 14.7667,
        "HImin": 6.40302,
        "HImean": 10.2599,
        "HImax": 14.0271
    },
    {
        "Year": 1982,
        "Month": 1,
        "Tmin": 10.3389,
        "Tmean": 14.1222,
        "Tmax": 17.5019,
        "Td": 10.3722,
        "RHmean": 78.3829,
        "RHmax": 63.6444,
        "WBGTmin": 10.5689,
        "WBGTmean": 12.6951,
        "WBGTmax": 14.7305,
        "WBGTmaxSun": 17.1905,
        "UTCImin": 11.3631,
        "UTCImean": 14.632,
        "UTCImax": 17.5026,
        "HImin": 9.92938,
        "HImean": 13.6372,
        "HImax": 16.9704
    },
    {
        "Year": 1982,
        "Month": 2,
        "Tmin": 12.248,
        "Tmean": 15.379,
        "Tmax": 18.9484,
        "Td": 12.2222,
        "RHmean": 81.5975,
        "RHmax": 65.3673,
        "WBGTmin": 12.3504,
        "WBGTmean": 14.1349,
        "WBGTmax": 16.2461,
        "WBGTmaxSun": 18.365,
        "UTCImin": 13.3921,
        "UTCImean": 16.0678,
        "UTCImax": 19.0792,
        "HImin": 12.0642,
        "HImean": 15.1036,
        "HImax": 18.6068
    },
    {
        "Year": 1982,
        "Month": 3,
        "Tmin": 10.6264,
        "Tmean": 14.567,
        "Tmax": 18.228,
        "Td": 10.5268,
        "RHmean": 77.2457,
        "RHmax": 61.7686,
        "WBGTmin": 10.8023,
        "WBGTmean": 13.0499,
        "WBGTmax": 15.2515,
        "WBGTmaxSun": 16.8514,
        "UTCImin": 11.6506,
        "UTCImean": 15.059,
        "UTCImax": 18.1618,
        "HImin": 10.2382,
        "HImean": 14.0968,
        "HImax": 17.7203
    },
    {
        "Year": 1982,
        "Month": 4,
        "Tmin": 8.28927,
        "Tmean": 12.3774,
        "Tmax": 16.6935,
        "Td": 7.12836,
        "RHmean": 71.6036,
        "RHmax": 54.429,
        "WBGTmin": 8.07749,
        "WBGTmean": 10.5633,
        "WBGTmax": 13.249,
        "WBGTmaxSun": 14.3302,
        "UTCImin": 9.00788,
        "UTCImean": 12.6247,
        "UTCImax": 16.3256,
        "HImin": 7.55299,
        "HImean": 11.5407,
        "HImax": 15.8404
    },
    {
        "Year": 1982,
        "Month": 5,
        "Tmin": 6.78927,
        "Tmean": 10.3755,
        "Tmax": 14.2874,
        "Td": 6.6705,
        "RHmean": 78.6915,
        "RHmax": 61.921,
        "WBGTmin": 7.05394,
        "WBGTmean": 9.11994,
        "WBGTmax": 11.6353,
        "WBGTmaxSun": 12.3031,
        "UTCImin": 7.54962,
        "UTCImean": 10.7974,
        "UTCImax": 14.2113,
        "HImin": 5.98517,
        "HImean": 9.52347,
        "HImax": 13.389
    },
    {
        "Year": 1982,
        "Month": 6,
        "Tmin": 4.53704,
        "Tmean": 8.02778,
        "Tmax": 12.8556,
        "Td": 1.36296,
        "RHmean": 63.9868,
        "RHmax": 46.6503,
        "WBGTmin": 3.75934,
        "WBGTmean": 6.06368,
        "WBGTmax": 9.27825,
        "WBGTmaxSun": 9.8104,
        "UTCImin": 4.75433,
        "UTCImean": 8.01639,
        "UTCImax": 12.3611,
        "HImin": 3.1271,
        "HImean": 6.55658,
        "HImax": 11.4148
    },
    {
        "Year": 1982,
        "Month": 7,
        "Tmin": 3.00896,
        "Tmean": 6.69176,
        "Tmax": 11.5233,
        "Td": 0.281363,
        "RHmean": 65.0132,
        "RHmax": 47.4322,
        "WBGTmin": 2.50418,
        "WBGTmean": 4.87147,
        "WBGTmax": 8.14736,
        "WBGTmaxSun": 8.7727,
        "UTCImin": 3.12808,
        "UTCImean": 6.64994,
        "UTCImax": 11.0682,
        "HImin": 1.4728,
        "HImean": 5.11363,
        "HImax": 9.96959
    },
    {
        "Year": 1982,
        "Month": 8,
        "Tmin": 3.89074,
        "Tmean": 8.25926,
        "Tmax": 11.8352,
        "Td": 4.6963,
        "RHmean": 78.8587,
        "RHmax": 62.6882,
        "WBGTmin": 4.70963,
        "WBGTmean": 7.12274,
        "WBGTmax": 9.46413,
        "WBGTmaxSun": 10.4341,
        "UTCImin": 4.53797,
        "UTCImean": 8.6311,
        "UTCImax": 11.8118,
        "HImin": 2.82464,
        "HImean": 7.1998,
        "HImax": 10.7114
    },
    {
        "Year": 1982,
        "Month": 9,
        "Tmin": 5.52778,
        "Tmean": 9.90556,
        "Tmax": 13.4352,
        "Td": 5.8963,
        "RHmean": 76.7366,
        "RHmax": 61.2182,
        "WBGTmin": 5.94218,
        "WBGTmean": 8.55935,
        "WBGTmax": 10.8363,
        "WBGTmaxSun": 12.2543,
        "UTCImin": 6.25308,
        "UTCImean": 10.2701,
        "UTCImax": 13.3514,
        "HImin": 4.66327,
        "HImean": 8.95547,
        "HImax": 12.4332
    },
    {
        "Year": 1982,
        "Month": 10,
        "Tmin": 4.80159,
        "Tmean": 10.1171,
        "Tmax": 13.8651,
        "Td": 4.42659,
        "RHmean": 70.1723,
        "RHmax": 55.4714,
        "WBGTmin": 5.06719,
        "WBGTmean": 8.30009,
        "WBGTmax": 10.719,
        "WBGTmaxSun": 12.5867,
        "UTCImin": 5.37704,
        "UTCImean": 10.2803,
        "UTCImax": 13.5843,
        "HImin": 3.73974,
        "HImean": 9.01666,
        "HImax": 12.756
    },
    {
        "Year": 1982,
        "Month": 11,
        "Tmin": 8.21839,
        "Tmean": 11.5766,
        "Tmax": 14.4866,
        "Td": 7.87931,
        "RHmean": 78.7804,
        "RHmax": 65.8273,
        "WBGTmin": 8.29848,
        "WBGTmean": 10.2893,
        "WBGTmax": 12.1182,
        "WBGTmaxSun": 14.3999,
        "UTCImin": 9.03572,
        "UTCImean": 12.0431,
        "UTCImax": 14.5568,
        "HImin": 7.56246,
        "HImean": 10.8471,
        "HImax": 13.7102
    },
    {
        "Year": 1982,
        "Month": 12,
        "Tmin": 8.25269,
        "Tmean": 12.2079,
        "Tmax": 15.5358,
        "Td": 8.49641,
        "RHmean": 78.2601,
        "RHmax": 63.4765,
        "WBGTmin": 8.53918,
        "WBGTmean": 10.8732,
        "WBGTmax": 12.944,
        "WBGTmaxSun": 15.445,
        "UTCImin": 9.14154,
        "UTCImean": 12.6763,
        "UTCImax": 15.5241,
        "HImin": 7.67627,
        "HImean": 11.528,
        "HImax": 14.8032
    }
];

function averages({avg, n}, tempInfo) {
    if (tempInfo.WBGTmaxSun == null) {
        return {avg, n};
    }

    return {
        avg: (tempInfo.WBGTmaxSun + n * avg) / (n + 1),
        n:   n + 1,
    };
}

// Calculations
// ----------------------------------------------------------------------------

// Calculate the average and display.
const initialVals       = {avg: 0, n: 0};
const averageVals = array1.reduce(averages, initialVals).avg;
console.log("Average:", averageVals);

//PSEUDOCODE:
// for each month:
//      for each tempType:
//          call array1.reduce(averages, initialVals).avg;

var avgx = array1
  .filter((x) => {
      return x.Month === 1;
  })
  .map(function(obj) {return obj.WBGTmaxSun})
  .reduce(function(a, b) { return a + b });

console.log("Average:", avgx);```
</div>
</div>
</p>
<p>I have explored the functions <em>reduce()</em>, <em>map()</em>, and <em>filter()</em>.<br />
I managed to get the code to work for all months, but for only one temperature-type (WBGTmaxSun).</p>
<p>However, the result I want is an array containing all temperature-types, with each temperature-type having an array of temperatures for each month.  Here is a screenshot of the output of my existing code, however the code is inefficient and doesn't ignore nulls in the calculations:</p>
<p><img src="https://i.stack.imgur.com/gxf7L.png" alt="enter image description here" /></p>
<p>In the original array of objects, some temperature-type properties have null values, so they should not influence the average calculations.</p>
<p>I was hoping to use my current code in the jsfiddle inside 2 loops.  Here is some pseduocode:</p>
```for each month:
    for each tempType:
        call array1.reduce(averages, initialVals).avg;
```

However, I don't know how to pass parameters for the month and temperature-type into the averages() function.

I could use multiple loops to achieve all of this, but I want to write efficient code.  I have studied this page for assistance: FUNCTIONAL JAVASCRIPT, however I've hit a wall.

Body:
I have a large JavaScript array of objects.  Each object contains temperature data for each month for many years.  I would like to find the average temperature data for each temperature-type for each month (there are actually 13 months in my data intentionally, so I want averages for 13 months).

In this jsfiddle, I have been playing with a very small subset of the data:

const array1 =
[
    {
        "Year": 1980,
        "Month": 0,
        "Tmin": null,
        "Tmean": 11.1914,
        "Tmax": null,
        "Td": 7.01668,
        "RHmean": 76.1544,
        "RHmax": 61.7298,
        "WBGTmin": 8.3829,
        "WBGTmean": 9.75617,
        "WBGTmax": null,
        "WBGTmaxSun": null,
        "UTCImin": 9.41549,
        "UTCImean": 11.5612,
        "UTCImax": null,
        "HImin": 8.03456,
        "HImean": 10.9305,
        "HImax": 14.2173
    },
    {
        "Year": 1980,
        "Month": 1,
        "Tmin": 11.931,
        "Tmean": 15.0778,
        "Tmax": 18.1379,
        "Td": 10.4667,
        "RHmean": 74.6458,
        "RHmax": 61.0794,
        "WBGTmin": 11.3724,
        "WBGTmean": 13.3417,
        "WBGTmax": 15.1419,
        "WBGTmaxSun": null,
        "UTCImin": 12.7629,
        "UTCImean": 15.5132,
        "UTCImax": 18.0733,
        "HImin": 11.5267,
        "HImean": 14.5908,
        "HImax": 17.6032
    },
    {
        "Year": 1980,
        "Month": 2,
        "Tmin": 10.8621,
        "Tmean": 14.3429,
        "Tmax": 18.1379,
        "Td": 9.55555,
        "RHmean": 73.3624,
        "RHmax": 58.0879,
        "WBGTmin": 10.4187,
        "WBGTmean": 12.5424,
        "WBGTmax": 14.8529,
        "WBGTmaxSun": null,
        "UTCImin": 11.663,
        "UTCImean": 14.6836,
        "UTCImax": 17.9196,
        "HImin": 10.3846,
        "HImean": 13.7489,
        "HImax": 17.5251
    },
    {
        "Year": 1980,
        "Month": 3,
        "Tmin": 11.069,
        "Tmean": 13.7278,
        "Tmax": 17.3103,
        "Td": 9.47038,
        "RHmean": 76.4473,
        "RHmax": 61.5543,
        "WBGTmin": 10.6146,
        "WBGTmean": 12.1394,
        "WBGTmax": 14.3354,
        "WBGTmaxSun": null,
        "UTCImin": 11.8356,
        "UTCImean": 14.1294,
        "UTCImax": 17.2034,
        "HImin": 10.57,
        "HImean": 13.1527,
        "HImax": 16.7052
    },
    {
        "Year": 1980,
        "Month": 4,
        "Tmin": 9.37931,
        "Tmean": 12.9241,
        "Tmax": 16.2759,
        "Td": 8.23148,
        "RHmean": 74.3115,
        "RHmax": 59.5891,
        "WBGTmin": 9.04303,
        "WBGTmean": 11.2406,
        "WBGTmax": 13.2503,
        "WBGTmaxSun": null,
        "UTCImin": 10.0756,
        "UTCImean": 13.2498,
        "UTCImax": 16.0892,
        "HImin": 8.72126,
        "HImean": 12.2128,
        "HImax": 15.5158
    },
    {
        "Year": 1980,
        "Month": 5,
        "Tmin": 8.07407,
        "Tmean": 10.6399,
        "Tmax": 14.4444,
        "Td": null,
        "RHmean": 76.2411,
        "RHmax": 60.2131,
        "WBGTmin": 7.57442,
        "WBGTmean": null,
        "WBGTmax": null,
        "WBGTmaxSun": null,
        "UTCImin": 8.70486,
        "UTCImean": null,
        "UTCImax": null,
        "HImin": 7.28312,
        "HImean": 9.75634,
        "HImax": 13.4938
    },
    {
        "Year": 1980,
        "Month": 7,
        "Tmin": 3.87097,
        "Tmean": 6.74194,
        "Tmax": 10.8065,
        "Td": 2.06452,
        "RHmean": 72.9362,
        "RHmax": 55.8054,
        "WBGTmin": 3.4279,
        "WBGTmean": 5.32629,
        "WBGTmax": 8.05513,
        "WBGTmaxSun": null,
        "UTCImin": 4.16556,
        "UTCImean": 6.88706,
        "UTCImax": 10.5796,
        "HImin": 2.5963,
        "HImean": 5.3759,
        "HImax": 9.3998
    },
    {
        "Year": 1980,
        "Month": 9,
        "Tmin": 6.23333,
        "Tmean": 8.97223,
        "Tmax": 11.6,
        "Td": 6.1037,
        "RHmean": 82.351,
        "RHmax": 69.5854,
        "WBGTmin": 6.31845,
        "WBGTmean": 8.00618,
        "WBGTmax": 9.71308,
        "WBGTmaxSun": null,
        "UTCImin": 6.92209,
        "UTCImean": 9.45113,
        "UTCImax": 11.7794,
        "HImin": 5.4295,
        "HImean": 8.07536,
        "HImax": 10.6328
    },
    {
        "Year": 1980,
        "Month": 10,
        "Tmin": 8.43333,
        "Tmean": 11.2852,
        "Tmax": 13.6667,
        "Td": 7.64815,
        "RHmean": 78.9403,
        "RHmax": 67.924,
        "WBGTmin": 8.29363,
        "WBGTmean": 10.0097,
        "WBGTmax": 11.5281,
        "WBGTmaxSun": null,
        "UTCImin": 9.19437,
        "UTCImean": 11.7425,
        "UTCImax": 13.8014,
        "HImin": 7.76501,
        "HImean": 10.5307,
        "HImax": 12.863
    },
    {
        "Year": 1981,
        "Month": 0,
        "Tmin": 8.54919,
        "Tmean": 11.5048,
        "Tmax": 14.5909,
        "Td": 7.70727,
        "RHmean": 79.2693,
        "RHmax": 65.5782,
        "WBGTmin": 8.81321,
        "WBGTmean": 10.2214,
        "WBGTmax": 12.1636,
        "WBGTmaxSun": 13.6712,
        "UTCImin": 9.60639,
        "UTCImean": 11.9768,
        "UTCImax": 14.6651,
        "HImin": 8.13911,
        "HImean": 11.1262,
        "HImax": 14.1329
    },
    {
        "Year": 1981,
        "Month": 1,
        "Tmin": 10.9355,
        "Tmean": 14.6649,
        "Tmax": 18.1935,
        "Td": 12.0968,
        "RHmean": 84.7151,
        "RHmax": 67.9045,
        "WBGTmin": 11.7611,
        "WBGTmean": 13.6596,
        "WBGTmax": 15.7362,
        "WBGTmaxSun": 18.1962,
        "UTCImin": 12.2129,
        "UTCImean": 15.4285,
        "UTCImax": 18.4067,
        "HImin": 10.6675,
        "HImean": 14.3994,
        "HImax": 17.8426
    },
    {
        "Year": 1981,
        "Month": 2,
        "Tmin": 12.0741,
        "Tmean": 14.5041,
        "Tmax": 17.5185,
        "Td": 12.251,
        "RHmean": 86.5258,
        "RHmax": 72.0491,
        "WBGTmin": 12.3043,
        "WBGTmean": 13.6124,
        "WBGTmax": 15.4261,
        "WBGTmaxSun": 17.545,
        "UTCImin": 13.2307,
        "UTCImean": 15.3403,
        "UTCImax": 17.8944,
        "HImin": 11.8769,
        "HImean": 14.2698,
        "HImax": 17.2081
    },
    {
        "Year": 1981,
        "Month": 3,
        "Tmin": 12.4074,
        "Tmean": 15.4167,
        "Tmax": 18.2593,
        "Td": 12.6071,
        "RHmean": 83.9611,
        "RHmax": 70.3348,
        "WBGTmin": 12.668,
        "WBGTmean": 14.3096,
        "WBGTmax": 15.9688,
        "WBGTmaxSun": 17.5687,
        "UTCImin": 13.5998,
        "UTCImean": 16.1949,
        "UTCImax": 18.5757,
        "HImin": 12.2142,
        "HImean": 15.2067,
        "HImax": 17.9783
    },
    {
        "Year": 1981,
        "Month": 4,
        "Tmin": 10,
        "Tmean": 12.7361,
        "Tmax": 15.8571,
        "Td": 9.64087,
        "RHmean": 82.5259,
        "RHmax": 67.9274,
        "WBGTmin": 10.0824,
        "WBGTmean": 11.6051,
        "WBGTmax": 13.5108,
        "WBGTmaxSun": 14.592,
        "UTCImin": 10.9405,
        "UTCImean": 13.3256,
        "UTCImax": 15.999,
        "HImin": 9.51275,
        "HImean": 12.2205,
        "HImax": 15.2729
    },
    {
        "Year": 1981,
        "Month": 5,
        "Tmin": 7.77419,
        "Tmean": 10.0627,
        "Tmax": 13.6129,
        "Td": 5.78494,
        "RHmean": 75.9491,
        "RHmax": 61.0582,
        "WBGTmin": 7.20217,
        "WBGTmean": 8.64684,
        "WBGTmax": 10.9509,
        "WBGTmaxSun": 11.6187,
        "UTCImin": 8.33175,
        "UTCImean": 10.4036,
        "UTCImax": 13.5211,
        "HImin": 6.89413,
        "HImean": 9.10776,
        "HImax": 12.6245
    },
    {
        "Year": 1981,
        "Month": 7,
        "Tmin": 4.9,
        "Tmean": 7.17407,
        "Tmax": 10.3667,
        "Td": 2.70556,
        "RHmean": 74.8556,
        "RHmax": 61.1368,
        "WBGTmin": 4.34986,
        "WBGTmean": 5.8641,
        "WBGTmax": 7.98966,
        "WBGTmaxSun": 8.615,
        "UTCImin": 5.264,
        "UTCImean": 7.39827,
        "UTCImax": 10.2977,
        "HImin": 3.69173,
        "HImean": 5.90138,
        "HImax": 9.05522
    },
    {
        "Year": 1981,
        "Month": 8,
        "Tmin": 4.45161,
        "Tmean": 7.92652,
        "Tmax": 11.871,
        "Td": 0.390681,
        "RHmean": 61.2032,
        "RHmax": 47.431,
        "WBGTmin": 3.40579,
        "WBGTmean": 5.77148,
        "WBGTmax": 8.40882,
        "WBGTmaxSun": 9.3788,
        "UTCImin": 4.54988,
        "UTCImean": 7.83204,
        "UTCImax": 11.4088,
        "HImin": 2.9492,
        "HImean": 6.37245,
        "HImax": 10.352
    },
    {
        "Year": 1981,
        "Month": 9,
        "Tmin": 4.2,
        "Tmean": 8.3537,
        "Tmax": 10.8667,
        "Td": 5.32407,
        "RHmean": 81.6902,
        "RHmax": 69.417,
        "WBGTmin": 5.1251,
        "WBGTmean": 7.35119,
        "WBGTmax": 9.0068,
        "WBGTmaxSun": 10.4248,
        "UTCImin": 4.87588,
        "UTCImean": 8.78665,
        "UTCImax": 11.0342,
        "HImin": 3.20796,
        "HImean": 7.37767,
        "HImax": 9.82164
    },
    {
        "Year": 1981,
        "Month": 10,
        "Tmin": 7.48387,
        "Tmean": 11.0681,
        "Tmax": 13.6774,
        "Td": 7.32616,
        "RHmean": 78.8369,
        "RHmax": 67.1361,
        "WBGTmin": 7.72401,
        "WBGTmean": 9.77781,
        "WBGTmax": 11.4299,
        "WBGTmaxSun": 13.2976,
        "UTCImin": 8.26469,
        "UTCImean": 11.5077,
        "UTCImax": 13.7745,
        "HImin": 6.74846,
        "HImean": 10.2892,
        "HImax": 12.8542
    },
    {
        "Year": 1981,
        "Month": 11,
        "Tmin": 10.1379,
        "Tmean": 13.2088,
        "Tmax": 16.0345,
        "Td": 9.78353,
        "RHmean": 80.1912,
        "RHmax": 67.215,
        "WBGTmin": 10.1662,
        "WBGTmean": 11.9142,
        "WBGTmax": 13.6553,
        "WBGTmaxSun": 15.937,
        "UTCImin": 11.0545,
        "UTCImean": 13.74,
        "UTCImax": 16.1454,
        "HImin": 9.6793,
        "HImean": 12.6796,
        "HImax": 15.4494
    },
    {
        "Year": 1981,
        "Month": 12,
        "Tmin": 12.3262,
        "Tmean": 14.8907,
        "Tmax": 17.3871,
        "Td": 11.7276,
        "RHmean": 81.5082,
        "RHmax": 69.7501,
        "WBGTmin": 12.1564,
        "WBGTmean": 13.6467,
        "WBGTmax": 15.1406,
        "WBGTmaxSun": 17.6416,
        "UTCImin": 13.3456,
        "UTCImean": 15.5432,
        "UTCImax": 17.6521,
        "HImin": 12.0881,
        "HImean": 14.5641,
        "HImax": 17.0036
    },
    {
        "Year": 1982,
        "Month": 0,
        "Tmin": 7.17557,
        "Tmean": 11.1063,
        "Tmax": 14.9062,
        "Td": 6.62961,
        "RHmean": 74.9441,
        "RHmax": 59.1579,
        "WBGTmin": 7.3061,
        "WBGTmean": 9.60836,
        "WBGTmax": 12.0246,
        "WBGTmaxSun": 13.5322,
        "UTCImin": 7.93259,
        "UTCImean": 11.4494,
        "UTCImax": 14.7667,
        "HImin": 6.40302,
        "HImean": 10.2599,
        "HImax": 14.0271
    },
    {
        "Year": 1982,
        "Month": 1,
        "Tmin": 10.3389,
        "Tmean": 14.1222,
        "Tmax": 17.5019,
        "Td": 10.3722,
        "RHmean": 78.3829,
        "RHmax": 63.6444,
        "WBGTmin": 10.5689,
        "WBGTmean": 12.6951,
        "WBGTmax": 14.7305,
        "WBGTmaxSun": 17.1905,
        "UTCImin": 11.3631,
        "UTCImean": 14.632,
        "UTCImax": 17.5026,
        "HImin": 9.92938,
        "HImean": 13.6372,
        "HImax": 16.9704
    },
    {
        "Year": 1982,
        "Month": 2,
        "Tmin": 12.248,
        "Tmean": 15.379,
        "Tmax": 18.9484,
        "Td": 12.2222,
        "RHmean": 81.5975,
        "RHmax": 65.3673,
        "WBGTmin": 12.3504,
        "WBGTmean": 14.1349,
        "WBGTmax": 16.2461,
        "WBGTmaxSun": 18.365,
        "UTCImin": 13.3921,
        "UTCImean": 16.0678,
        "UTCImax": 19.0792,
        "HImin": 12.0642,
        "HImean": 15.1036,
        "HImax": 18.6068
    },
    {
        "Year": 1982,
        "Month": 3,
        "Tmin": 10.6264,
        "Tmean": 14.567,
        "Tmax": 18.228,
        "Td": 10.5268,
        "RHmean": 77.2457,
        "RHmax": 61.7686,
        "WBGTmin": 10.8023,
        "WBGTmean": 13.0499,
        "WBGTmax": 15.2515,
        "WBGTmaxSun": 16.8514,
        "UTCImin": 11.6506,
        "UTCImean": 15.059,
        "UTCImax": 18.1618,
        "HImin": 10.2382,
        "HImean": 14.0968,
        "HImax": 17.7203
    },
    {
        "Year": 1982,
        "Month": 4,
        "Tmin": 8.28927,
        "Tmean": 12.3774,
        "Tmax": 16.6935,
        "Td": 7.12836,
        "RHmean": 71.6036,
        "RHmax": 54.429,
        "WBGTmin": 8.07749,
        "WBGTmean": 10.5633,
        "WBGTmax": 13.249,
        "WBGTmaxSun": 14.3302,
        "UTCImin": 9.00788,
        "UTCImean": 12.6247,
        "UTCImax": 16.3256,
        "HImin": 7.55299,
        "HImean": 11.5407,
        "HImax": 15.8404
    },
    {
        "Year": 1982,
        "Month": 5,
        "Tmin": 6.78927,
        "Tmean": 10.3755,
        "Tmax": 14.2874,
        "Td": 6.6705,
        "RHmean": 78.6915,
        "RHmax": 61.921,
        "WBGTmin": 7.05394,
        "WBGTmean": 9.11994,
        "WBGTmax": 11.6353,
        "WBGTmaxSun": 12.3031,
        "UTCImin": 7.54962,
        "UTCImean": 10.7974,
        "UTCImax": 14.2113,
        "HImin": 5.98517,
        "HImean": 9.52347,
        "HImax": 13.389
    },
    {
        "Year": 1982,
        "Month": 6,
        "Tmin": 4.53704,
        "Tmean": 8.02778,
        "Tmax": 12.8556,
        "Td": 1.36296,
        "RHmean": 63.9868,
        "RHmax": 46.6503,
        "WBGTmin": 3.75934,
        "WBGTmean": 6.06368,
        "WBGTmax": 9.27825,
        "WBGTmaxSun": 9.8104,
        "UTCImin": 4.75433,
        "UTCImean": 8.01639,
        "UTCImax": 12.3611,
        "HImin": 3.1271,
        "HImean": 6.55658,
        "HImax": 11.4148
    },
    {
        "Year": 1982,
        "Month": 7,
        "Tmin": 3.00896,
        "Tmean": 6.69176,
        "Tmax": 11.5233,
        "Td": 0.281363,
        "RHmean": 65.0132,
        "RHmax": 47.4322,
        "WBGTmin": 2.50418,
        "WBGTmean": 4.87147,
        "WBGTmax": 8.14736,
        "WBGTmaxSun": 8.7727,
        "UTCImin": 3.12808,
        "UTCImean": 6.64994,
        "UTCImax": 11.0682,
        "HImin": 1.4728,
        "HImean": 5.11363,
        "HImax": 9.96959
    },
    {
        "Year": 1982,
        "Month": 8,
        "Tmin": 3.89074,
        "Tmean": 8.25926,
        "Tmax": 11.8352,
        "Td": 4.6963,
        "RHmean": 78.8587,
        "RHmax": 62.6882,
        "WBGTmin": 4.70963,
        "WBGTmean": 7.12274,
        "WBGTmax": 9.46413,
        "WBGTmaxSun": 10.4341,
        "UTCImin": 4.53797,
        "UTCImean": 8.6311,
        "UTCImax": 11.8118,
        "HImin": 2.82464,
        "HImean": 7.1998,
        "HImax": 10.7114
    },
    {
        "Year": 1982,
        "Month": 9,
        "Tmin": 5.52778,
        "Tmean": 9.90556,
        "Tmax": 13.4352,
        "Td": 5.8963,
        "RHmean": 76.7366,
        "RHmax": 61.2182,
        "WBGTmin": 5.94218,
        "WBGTmean": 8.55935,
        "WBGTmax": 10.8363,
        "WBGTmaxSun": 12.2543,
        "UTCImin": 6.25308,
        "UTCImean": 10.2701,
        "UTCImax": 13.3514,
        "HImin": 4.66327,
        "HImean": 8.95547,
        "HImax": 12.4332
    },
    {
        "Year": 1982,
        "Month": 10,
        "Tmin": 4.80159,
        "Tmean": 10.1171,
        "Tmax": 13.8651,
        "Td": 4.42659,
        "RHmean": 70.1723,
        "RHmax": 55.4714,
        "WBGTmin": 5.06719,
        "WBGTmean": 8.30009,
        "WBGTmax": 10.719,
        "WBGTmaxSun": 12.5867,
        "UTCImin": 5.37704,
        "UTCImean": 10.2803,
        "UTCImax": 13.5843,
        "HImin": 3.73974,
        "HImean": 9.01666,
        "HImax": 12.756
    },
    {
        "Year": 1982,
        "Month": 11,
        "Tmin": 8.21839,
        "Tmean": 11.5766,
        "Tmax": 14.4866,
        "Td": 7.87931,
        "RHmean": 78.7804,
        "RHmax": 65.8273,
        "WBGTmin": 8.29848,
        "WBGTmean": 10.2893,
        "WBGTmax": 12.1182,
        "WBGTmaxSun": 14.3999,
        "UTCImin": 9.03572,
        "UTCImean": 12.0431,
        "UTCImax": 14.5568,
        "HImin": 7.56246,
        "HImean": 10.8471,
        "HImax": 13.7102
    },
    {
        "Year": 1982,
        "Month": 12,
        "Tmin": 8.25269,
        "Tmean": 12.2079,
        "Tmax": 15.5358,
        "Td": 8.49641,
        "RHmean": 78.2601,
        "RHmax": 63.4765,
        "WBGTmin": 8.53918,
        "WBGTmean": 10.8732,
        "WBGTmax": 12.944,
        "WBGTmaxSun": 15.445,
        "UTCImin": 9.14154,
        "UTCImean": 12.6763,
        "UTCImax": 15.5241,
        "HImin": 7.67627,
        "HImean": 11.528,
        "HImax": 14.8032
    }
];

function averages({avg, n}, tempInfo) {
    if (tempInfo.WBGTmaxSun == null) {
        return {avg, n};
    }

    return {
        avg: (tempInfo.WBGTmaxSun + n * avg) / (n + 1),
        n:   n + 1,
    };
}

// Calculations
// ----------------------------------------------------------------------------

// Calculate the average and display.
const initialVals       = {avg: 0, n: 0};
const averageVals = array1.reduce(averages, initialVals).avg;
console.log("Average:", averageVals);

//PSEUDOCODE:
// for each month:
//      for each tempType:
//          call array1.reduce(averages, initialVals).avg;

var avgx = array1
  .filter((x) => {
      return x.Month === 1;
  })
  .map(function(obj) {return obj.WBGTmaxSun})
  .reduce(function(a, b) { return a + b });

console.log("Average:", avgx);

I have explored the functions reduce(), map(), and filter().

I managed to get the code to work for all months, but for only one temperature-type (WBGTmaxSun).

However, the result I want is an array containing all temperature-types, with each temperature-type having an array of temperatures for each month.  Here is a screenshot of the output of my existing code, however the code is inefficient and doesn't ignore nulls in the calculations:

In the original array of objects, some temperature-type properties have null values, so they should not influence the average calculations.

I was hoping to use my current code in the jsfiddle inside 2 loops.  Here is some pseduocode:

for each month:
    for each tempType:
        call array1.reduce(averages, initialVals).avg;

However, I don't know how to pass parameters for the month and temperature-type into the averages() function.

I could use multiple loops to achieve all of this, but I want to write efficient code.  I have studied this page for assistance: FUNCTIONAL JAVASCRIPT, however I've hit a wall.

Body:
I have solved this with this code:

const array1 =
[
    {
        "Year": 1980,
        "Month": 0,
        "Tmin": null,
        "Tmean": 11.1914,
        "Tmax": null,
        "Td": 7.01668,
        "RHmean": 76.1544,
        "RHmax": 61.7298,
        "WBGTmin": 8.3829,
        "WBGTmean": 9.75617,
        "WBGTmax": null,
        "WBGTmaxSun": null,
        "UTCImin": 9.41549,
        "UTCImean": 11.5612,
        "UTCImax": null,
        "HImin": 8.03456,
        "HImean": 10.9305,
        "HImax": 14.2173
    },
    {
        "Year": 1980,
        "Month": 1,
        "Tmin": 11.931,
        "Tmean": 15.0778,
        "Tmax": 18.1379,
        "Td": 10.4667,
        "RHmean": 74.6458,
        "RHmax": 61.0794,
        "WBGTmin": 11.3724,
        "WBGTmean": 13.3417,
        "WBGTmax": 15.1419,
        "WBGTmaxSun": null,
        "UTCImin": 12.7629,
        "UTCImean": 15.5132,
        "UTCImax": 18.0733,
        "HImin": 11.5267,
        "HImean": 14.5908,
        "HImax": 17.6032
    },
    {
        "Year": 1980,
        "Month": 2,
        "Tmin": 10.8621,
        "Tmean": 14.3429,
        "Tmax": 18.1379,
        "Td": 9.55555,
        "RHmean": 73.3624,
        "RHmax": 58.0879,
        "WBGTmin": 10.4187,
        "WBGTmean": 12.5424,
        "WBGTmax": 14.8529,
        "WBGTmaxSun": null,
        "UTCImin": 11.663,
        "UTCImean": 14.6836,
        "UTCImax": 17.9196,
        "HImin": 10.3846,
        "HImean": 13.7489,
        "HImax": 17.5251
    },
    {
        "Year": 1980,
        "Month": 3,
        "Tmin": 11.069,
        "Tmean": 13.7278,
        "Tmax": 17.3103,
        "Td": 9.47038,
        "RHmean": 76.4473,
        "RHmax": 61.5543,
        "WBGTmin": 10.6146,
        "WBGTmean": 12.1394,
        "WBGTmax": 14.3354,
        "WBGTmaxSun": null,
        "UTCImin": 11.8356,
        "UTCImean": 14.1294,
        "UTCImax": 17.2034,
        "HImin": 10.57,
        "HImean": 13.1527,
        "HImax": 16.7052
    },
    {
        "Year": 1980,
        "Month": 4,
        "Tmin": 9.37931,
        "Tmean": 12.9241,
        "Tmax": 16.2759,
        "Td": 8.23148,
        "RHmean": 74.3115,
        "RHmax": 59.5891,
        "WBGTmin": 9.04303,
        "WBGTmean": 11.2406,
        "WBGTmax": 13.2503,
        "WBGTmaxSun": null,
        "UTCImin": 10.0756,
        "UTCImean": 13.2498,
        "UTCImax": 16.0892,
        "HImin": 8.72126,
        "HImean": 12.2128,
        "HImax": 15.5158
    },
    {
        "Year": 1980,
        "Month": 5,
        "Tmin": 8.07407,
        "Tmean": 10.6399,
        "Tmax": 14.4444,
        "Td": null,
        "RHmean": 76.2411,
        "RHmax": 60.2131,
        "WBGTmin": 7.57442,
        "WBGTmean": null,
        "WBGTmax": null,
        "WBGTmaxSun": null,
        "UTCImin": 8.70486,
        "UTCImean": null,
        "UTCImax": null,
        "HImin": 7.28312,
        "HImean": 9.75634,
        "HImax": 13.4938
    },
    {
        "Year": 1980,
        "Month": 7,
        "Tmin": 3.87097,
        "Tmean": 6.74194,
        "Tmax": 10.8065,
        "Td": 2.06452,
        "RHmean": 72.9362,
        "RHmax": 55.8054,
        "WBGTmin": 3.4279,
        "WBGTmean": 5.32629,
        "WBGTmax": 8.05513,
        "WBGTmaxSun": null,
        "UTCImin": 4.16556,
        "UTCImean": 6.88706,
        "UTCImax": 10.5796,
        "HImin": 2.5963,
        "HImean": 5.3759,
        "HImax": 9.3998
    },
    {
        "Year": 1980,
        "Month": 9,
        "Tmin": 6.23333,
        "Tmean": 8.97223,
        "Tmax": 11.6,
        "Td": 6.1037,
        "RHmean": 82.351,
        "RHmax": 69.5854,
        "WBGTmin": 6.31845,
        "WBGTmean": 8.00618,
        "WBGTmax": 9.71308,
        "WBGTmaxSun": null,
        "UTCImin": 6.92209,
        "UTCImean": 9.45113,
        "UTCImax": 11.7794,
        "HImin": 5.4295,
        "HImean": 8.07536,
        "HImax": 10.6328
    },
    {
        "Year": 1980,
        "Month": 10,
        "Tmin": 8.43333,
        "Tmean": 11.2852,
        "Tmax": 13.6667,
        "Td": 7.64815,
        "RHmean": 78.9403,
        "RHmax": 67.924,
        "WBGTmin": 8.29363,
        "WBGTmean": 10.0097,
        "WBGTmax": 11.5281,
        "WBGTmaxSun": null,
        "UTCImin": 9.19437,
        "UTCImean": 11.7425,
        "UTCImax": 13.8014,
        "HImin": 7.76501,
        "HImean": 10.5307,
        "HImax": 12.863
    },
    {
        "Year": 1981,
        "Month": 0,
        "Tmin": 8.54919,
        "Tmean": 11.5048,
        "Tmax": 14.5909,
        "Td": 7.70727,
        "RHmean": 79.2693,
        "RHmax": 65.5782,
        "WBGTmin": 8.81321,
        "WBGTmean": 10.2214,
        "WBGTmax": 12.1636,
        "WBGTmaxSun": 13.6712,
        "UTCImin": 9.60639,
        "UTCImean": 11.9768,
        "UTCImax": 14.6651,
        "HImin": 8.13911,
        "HImean": 11.1262,
        "HImax": 14.1329
    },
    {
        "Year": 1981,
        "Month": 1,
        "Tmin": 10.9355,
        "Tmean": 14.6649,
        "Tmax": 18.1935,
        "Td": 12.0968,
        "RHmean": 84.7151,
        "RHmax": 67.9045,
        "WBGTmin": 11.7611,
        "WBGTmean": 13.6596,
        "WBGTmax": 15.7362,
        "WBGTmaxSun": 18.1962,
        "UTCImin": 12.2129,
        "UTCImean": 15.4285,
        "UTCImax": 18.4067,
        "HImin": 10.6675,
        "HImean": 14.3994,
        "HImax": 17.8426
    },
    {
        "Year": 1981,
        "Month": 2,
        "Tmin": 12.0741,
        "Tmean": 14.5041,
        "Tmax": 17.5185,
        "Td": 12.251,
        "RHmean": 86.5258,
        "RHmax": 72.0491,
        "WBGTmin": 12.3043,
        "WBGTmean": 13.6124,
        "WBGTmax": 15.4261,
        "WBGTmaxSun": 17.545,
        "UTCImin": 13.2307,
        "UTCImean": 15.3403,
        "UTCImax": 17.8944,
        "HImin": 11.8769,
        "HImean": 14.2698,
        "HImax": 17.2081
    },
    {
        "Year": 1981,
        "Month": 3,
        "Tmin": 12.4074,
        "Tmean": 15.4167,
        "Tmax": 18.2593,
        "Td": 12.6071,
        "RHmean": 83.9611,
        "RHmax": 70.3348,
        "WBGTmin": 12.668,
        "WBGTmean": 14.3096,
        "WBGTmax": 15.9688,
        "WBGTmaxSun": 17.5687,
        "UTCImin": 13.5998,
        "UTCImean": 16.1949,
        "UTCImax": 18.5757,
        "HImin": 12.2142,
        "HImean": 15.2067,
        "HImax": 17.9783
    },
    {
        "Year": 1981,
        "Month": 4,
        "Tmin": 10,
        "Tmean": 12.7361,
        "Tmax": 15.8571,
        "Td": 9.64087,
        "RHmean": 82.5259,
        "RHmax": 67.9274,
        "WBGTmin": 10.0824,
        "WBGTmean": 11.6051,
        "WBGTmax": 13.5108,
        "WBGTmaxSun": 14.592,
        "UTCImin": 10.9405,
        "UTCImean": 13.3256,
        "UTCImax": 15.999,
        "HImin": 9.51275,
        "HImean": 12.2205,
        "HImax": 15.2729
    },
    {
        "Year": 1981,
        "Month": 5,
        "Tmin": 7.77419,
        "Tmean": 10.0627,
        "Tmax": 13.6129,
        "Td": 5.78494,
        "RHmean": 75.9491,
        "RHmax": 61.0582,
        "WBGTmin": 7.20217,
        "WBGTmean": 8.64684,
        "WBGTmax": 10.9509,
        "WBGTmaxSun": 11.6187,
        "UTCImin": 8.33175,
        "UTCImean": 10.4036,
        "UTCImax": 13.5211,
        "HImin": 6.89413,
        "HImean": 9.10776,
        "HImax": 12.6245
    },
    {
        "Year": 1981,
        "Month": 7,
        "Tmin": 4.9,
        "Tmean": 7.17407,
        "Tmax": 10.3667,
        "Td": 2.70556,
        "RHmean": 74.8556,
        "RHmax": 61.1368,
        "WBGTmin": 4.34986,
        "WBGTmean": 5.8641,
        "WBGTmax": 7.98966,
        "WBGTmaxSun": 8.615,
        "UTCImin": 5.264,
        "UTCImean": 7.39827,
        "UTCImax": 10.2977,
        "HImin": 3.69173,
        "HImean": 5.90138,
        "HImax": 9.05522
    },
    {
        "Year": 1981,
        "Month": 8,
        "Tmin": 4.45161,
        "Tmean": 7.92652,
        "Tmax": 11.871,
        "Td": 0.390681,
        "RHmean": 61.2032,
        "RHmax": 47.431,
        "WBGTmin": 3.40579,
        "WBGTmean": 5.77148,
        "WBGTmax": 8.40882,
        "WBGTmaxSun": 9.3788,
        "UTCImin": 4.54988,
        "UTCImean": 7.83204,
        "UTCImax": 11.4088,
        "HImin": 2.9492,
        "HImean": 6.37245,
        "HImax": 10.352
    },
    {
        "Year": 1981,
        "Month": 9,
        "Tmin": 4.2,
        "Tmean": 8.3537,
        "Tmax": 10.8667,
        "Td": 5.32407,
        "RHmean": 81.6902,
        "RHmax": 69.417,
        "WBGTmin": 5.1251,
        "WBGTmean": 7.35119,
        "WBGTmax": 9.0068,
        "WBGTmaxSun": 10.4248,
        "UTCImin": 4.87588,
        "UTCImean": 8.78665,
        "UTCImax": 11.0342,
        "HImin": 3.20796,
        "HImean": 7.37767,
        "HImax": 9.82164
    },
    {
        "Year": 1981,
        "Month": 10,
        "Tmin": 7.48387,
        "Tmean": 11.0681,
        "Tmax": 13.6774,
        "Td": 7.32616,
        "RHmean": 78.8369,
        "RHmax": 67.1361,
        "WBGTmin": 7.72401,
        "WBGTmean": 9.77781,
        "WBGTmax": 11.4299,
        "WBGTmaxSun": 13.2976,
        "UTCImin": 8.26469,
        "UTCImean": 11.5077,
        "UTCImax": 13.7745,
        "HImin": 6.74846,
        "HImean": 10.2892,
        "HImax": 12.8542
    },
    {
        "Year": 1981,
        "Month": 11,
        "Tmin": 10.1379,
        "Tmean": 13.2088,
        "Tmax": 16.0345,
        "Td": 9.78353,
        "RHmean": 80.1912,
        "RHmax": 67.215,
        "WBGTmin": 10.1662,
        "WBGTmean": 11.9142,
        "WBGTmax": 13.6553,
        "WBGTmaxSun": 15.937,
        "UTCImin": 11.0545,
        "UTCImean": 13.74,
        "UTCImax": 16.1454,
        "HImin": 9.6793,
        "HImean": 12.6796,
        "HImax": 15.4494
    },
    {
        "Year": 1981,
        "Month": 12,
        "Tmin": 12.3262,
        "Tmean": 14.8907,
        "Tmax": 17.3871,
        "Td": 11.7276,
        "RHmean": 81.5082,
        "RHmax": 69.7501,
        "WBGTmin": 12.1564,
        "WBGTmean": 13.6467,
        "WBGTmax": 15.1406,
        "WBGTmaxSun": 17.6416,
        "UTCImin": 13.3456,
        "UTCImean": 15.5432,
        "UTCImax": 17.6521,
        "HImin": 12.0881,
        "HImean": 14.5641,
        "HImax": 17.0036
    },
    {
        "Year": 1982,
        "Month": 0,
        "Tmin": 7.17557,
        "Tmean": 11.1063,
        "Tmax": 14.9062,
        "Td": 6.62961,
        "RHmean": 74.9441,
        "RHmax": 59.1579,
        "WBGTmin": 7.3061,
        "WBGTmean": 9.60836,
        "WBGTmax": 12.0246,
        "WBGTmaxSun": 13.5322,
        "UTCImin": 7.93259,
        "UTCImean": 11.4494,
        "UTCImax": 14.7667,
        "HImin": 6.40302,
        "HImean": 10.2599,
        "HImax": 14.0271
    },
    {
        "Year": 1982,
        "Month": 1,
        "Tmin": 10.3389,
        "Tmean": 14.1222,
        "Tmax": 17.5019,
        "Td": 10.3722,
        "RHmean": 78.3829,
        "RHmax": 63.6444,
        "WBGTmin": 10.5689,
        "WBGTmean": 12.6951,
        "WBGTmax": 14.7305,
        "WBGTmaxSun": 17.1905,
        "UTCImin": 11.3631,
        "UTCImean": 14.632,
        "UTCImax": 17.5026,
        "HImin": 9.92938,
        "HImean": 13.6372,
        "HImax": 16.9704
    },
    {
        "Year": 1982,
        "Month": 2,
        "Tmin": 12.248,
        "Tmean": 15.379,
        "Tmax": 18.9484,
        "Td": 12.2222,
        "RHmean": 81.5975,
        "RHmax": 65.3673,
        "WBGTmin": 12.3504,
        "WBGTmean": 14.1349,
        "WBGTmax": 16.2461,
        "WBGTmaxSun": 18.365,
        "UTCImin": 13.3921,
        "UTCImean": 16.0678,
        "UTCImax": 19.0792,
        "HImin": 12.0642,
        "HImean": 15.1036,
        "HImax": 18.6068
    },
    {
        "Year": 1982,
        "Month": 3,
        "Tmin": 10.6264,
        "Tmean": 14.567,
        "Tmax": 18.228,
        "Td": 10.5268,
        "RHmean": 77.2457,
        "RHmax": 61.7686,
        "WBGTmin": 10.8023,
        "WBGTmean": 13.0499,
        "WBGTmax": 15.2515,
        "WBGTmaxSun": 16.8514,
        "UTCImin": 11.6506,
        "UTCImean": 15.059,
        "UTCImax": 18.1618,
        "HImin": 10.2382,
        "HImean": 14.0968,
        "HImax": 17.7203
    },
    {
        "Year": 1982,
        "Month": 4,
        "Tmin": 8.28927,
        "Tmean": 12.3774,
        "Tmax": 16.6935,
        "Td": 7.12836,
        "RHmean": 71.6036,
        "RHmax": 54.429,
        "WBGTmin": 8.07749,
        "WBGTmean": 10.5633,
        "WBGTmax": 13.249,
        "WBGTmaxSun": 14.3302,
        "UTCImin": 9.00788,
        "UTCImean": 12.6247,
        "UTCImax": 16.3256,
        "HImin": 7.55299,
        "HImean": 11.5407,
        "HImax": 15.8404
    },
    {
        "Year": 1982,
        "Month": 5,
        "Tmin": 6.78927,
        "Tmean": 10.3755,
        "Tmax": 14.2874,
        "Td": 6.6705,
        "RHmean": 78.6915,
        "RHmax": 61.921,
        "WBGTmin": 7.05394,
        "WBGTmean": 9.11994,
        "WBGTmax": 11.6353,
        "WBGTmaxSun": 12.3031,
        "UTCImin": 7.54962,
        "UTCImean": 10.7974,
        "UTCImax": 14.2113,
        "HImin": 5.98517,
        "HImean": 9.52347,
        "HImax": 13.389
    },
    {
        "Year": 1982,
        "Month": 6,
        "Tmin": 4.53704,
        "Tmean": 8.02778,
        "Tmax": 12.8556,
        "Td": 1.36296,
        "RHmean": 63.9868,
        "RHmax": 46.6503,
        "WBGTmin": 3.75934,
        "WBGTmean": 6.06368,
        "WBGTmax": 9.27825,
        "WBGTmaxSun": 9.8104,
        "UTCImin": 4.75433,
        "UTCImean": 8.01639,
        "UTCImax": 12.3611,
        "HImin": 3.1271,
        "HImean": 6.55658,
        "HImax": 11.4148
    },
    {
        "Year": 1982,
        "Month": 7,
        "Tmin": 3.00896,
        "Tmean": 6.69176,
        "Tmax": 11.5233,
        "Td": 0.281363,
        "RHmean": 65.0132,
        "RHmax": 47.4322,
        "WBGTmin": 2.50418,
        "WBGTmean": 4.87147,
        "WBGTmax": 8.14736,
        "WBGTmaxSun": 8.7727,
        "UTCImin": 3.12808,
        "UTCImean": 6.64994,
        "UTCImax": 11.0682,
        "HImin": 1.4728,
        "HImean": 5.11363,
        "HImax": 9.96959
    },
    {
        "Year": 1982,
        "Month": 8,
        "Tmin": 3.89074,
        "Tmean": 8.25926,
        "Tmax": 11.8352,
        "Td": 4.6963,
        "RHmean": 78.8587,
        "RHmax": 62.6882,
        "WBGTmin": 4.70963,
        "WBGTmean": 7.12274,
        "WBGTmax": 9.46413,
        "WBGTmaxSun": 10.4341,
        "UTCImin": 4.53797,
        "UTCImean": 8.6311,
        "UTCImax": 11.8118,
        "HImin": 2.82464,
        "HImean": 7.1998,
        "HImax": 10.7114
    },
    {
        "Year": 1982,
        "Month": 9,
        "Tmin": 5.52778,
        "Tmean": 9.90556,
        "Tmax": 13.4352,
        "Td": 5.8963,
        "RHmean": 76.7366,
        "RHmax": 61.2182,
        "WBGTmin": 5.94218,
        "WBGTmean": 8.55935,
        "WBGTmax": 10.8363,
        "WBGTmaxSun": 12.2543,
        "UTCImin": 6.25308,
        "UTCImean": 10.2701,
        "UTCImax": 13.3514,
        "HImin": 4.66327,
        "HImean": 8.95547,
        "HImax": 12.4332
    },
    {
        "Year": 1982,
        "Month": 10,
        "Tmin": 4.80159,
        "Tmean": 10.1171,
        "Tmax": 13.8651,
        "Td": 4.42659,
        "RHmean": 70.1723,
        "RHmax": 55.4714,
        "WBGTmin": 5.06719,
        "WBGTmean": 8.30009,
        "WBGTmax": 10.719,
        "WBGTmaxSun": 12.5867,
        "UTCImin": 5.37704,
        "UTCImean": 10.2803,
        "UTCImax": 13.5843,
        "HImin": 3.73974,
        "HImean": 9.01666,
        "HImax": 12.756
    },
    {
        "Year": 1982,
        "Month": 11,
        "Tmin": 8.21839,
        "Tmean": 11.5766,
        "Tmax": 14.4866,
        "Td": 7.87931,
        "RHmean": 78.7804,
        "RHmax": 65.8273,
        "WBGTmin": 8.29848,
        "WBGTmean": 10.2893,
        "WBGTmax": 12.1182,
        "WBGTmaxSun": 14.3999,
        "UTCImin": 9.03572,
        "UTCImean": 12.0431,
        "UTCImax": 14.5568,
        "HImin": 7.56246,
        "HImean": 10.8471,
        "HImax": 13.7102
    },
    {
        "Year": 1982,
        "Month": 12,
        "Tmin": 8.25269,
        "Tmean": 12.2079,
        "Tmax": 15.5358,
        "Td": 8.49641,
        "RHmean": 78.2601,
        "RHmax": 63.4765,
        "WBGTmin": 8.53918,
        "WBGTmean": 10.8732,
        "WBGTmax": 12.944,
        "WBGTmaxSun": 15.445,
        "UTCImin": 9.14154,
        "UTCImean": 12.6763,
        "UTCImax": 15.5241,
        "HImin": 7.67627,
        "HImean": 11.528,
        "HImax": 14.8032
    }
];

const initialVals = {avg: 0, n: 0};

const tempTypes = ["Tmin", "Tmean", "Tmax","Td", "RHmean", "RHmax", "WBGTmin", "WBGTmean",  "WBGTmax","WBGTmaxSun", "UTCImin",   "UTCImean",  "UTCImax",         "HImin",  "HImean",  "HImax"];

for (var m = 0; m < 13; m++)
{
    for (var t = 0; t < tempTypes.length; t++)
    {
    var avgx = array1
    .filter((x) => {
      return x.Month === m;
    })
    .map(function(obj) {return obj[tempTypes[t]]})
    .reduce(averageCalcs, initialVals).avg;

    console.log(tempTypes[t] + ": Month: " + m + " : " + avgx);
    }
}

function averageCalcs({avg, n}, tempInfo) {
    if (tempInfo == null) {
        return {avg, n};
    }

    return {
        avg: (tempInfo + n * avg) / (n + 1),
        n:   n + 1,
    };
}


来源: stackexchange

问:
Three.js png texture - alpha renders as white instead as transparent
I'm creating a cube and I apply 6 different textures to each of it's faces. Each texture is a .png file and contains transparent parts. I'm also applying a color to the cube - I want to see that color trough png transparency.

Problem: Transparency renders as white color so I cannot see the base color of the cube (which renders ok if I remove the png texture)

How can I make the png transparency work? I tried playing with some material settings but none make it transparent.

Code for creating the cube and materials:

```<code>var geometry = new THREE.CubeGeometry(150, 200, 150, 2, 2, 2);
var materials = [];

// create textures array for all cube sides
for (var i = 1; i < 7; i++) {
   var img = new Image();
   img.src = 'img/s' + i + '.png';
   var tex = new THREE.Texture(img);
   img.tex = tex;

   img.onload = function () {
      this.tex.needsUpdate = true;
   };

   var mat = new THREE.MeshBasicMaterial({color: 0x00ff00, map: tex, transparent: true, overdraw: true });
   materials.push(mat);
}
cube = new THREE.Mesh(geometry, new THREE.MeshFaceMaterial(materials));
cube.position.y = 150;
scene.add(cube);
</code>```

EDIT:

Picture below shows the problem - with senthanal solution the left texture now renders ok - it is a png image without transparency - I set the transparency in code with

```<code>materialArray.push(new THREE.MeshBasicMaterial({ map: THREE.ImageUtils.loadTexture('img/s2.png'), transparent: true, opacity: 0.9, color: 0xFF0000 }));
</code>```

The right texture is also a png image - only that it has a transparent area (all that renders white should be pure red since it is transparent and should take the color from the cube?). How can I make that white part transparent?

答:
for those looking for a simple transparent png import helper:

import { MeshBasicMaterial, TextureLoader } from 'three'

export const importTexture = async(url, material) => {
    const loader = new TextureLoader()
    const texture = await loader.loadAsync(url)
    material.map = texture
    material.transparent = true
    material.needsUpdate = true
    return texture
}

//usage
const geo = new PlaneGeometry(1, 1)
const mat = new MeshBasicMaterial()
const mesh = new Mesh(geo, mat)
scene.add(mesh)
//this is asynchronous
importTexture('path/to/texture.png', mat)
```

ContentLicense: CC BY-SA 3.0

Body:
I'm creating a cube and I apply 6 different textures to each of it's faces. Each texture is a .png file and contains transparent parts. I'm also applying a color to the cube - I want to see that color trough png transparency.

Problem: Transparency renders as white color so I cannot see the base color of the cube (which renders ok if I remove the png texture)

How can I make the png transparency work? I tried playing with some material settings but none make it transparent.

Code for creating the cube and materials:

var geometry = new THREE.CubeGeometry(150, 200, 150, 2, 2, 2);
var materials = [];

// create textures array for all cube sides
for (var i = 1; i < 7; i++) {
   var img = new Image();
   img.src = 'img/s' + i + '.png';
   var tex = new THREE.Texture(img);
   img.tex = tex;

   img.onload = function () {
      this.tex.needsUpdate = true;
   };

   var mat = new THREE.MeshBasicMaterial({color: 0x00ff00, map: tex, transparent: true, overdraw: true });
   materials.push(mat);
}
cube = new THREE.Mesh(geometry, new THREE.MeshFaceMaterial(materials));
cube.position.y = 150;
scene.add(cube);

EDIT:

Picture below shows the problem - with senthanal solution the left texture now renders ok - it is a png image without transparency - I set the transparency in code with

materialArray.push(new THREE.MeshBasicMaterial({ map: THREE.ImageUtils.loadTexture('img/s2.png'), transparent: true, opacity: 0.9, color: 0xFF0000 }));

The right texture is also a png image - only that it has a transparent area (all that renders white should be pure red since it is transparent and should take the color from the cube?). How can I make that white part transparent?

ContentLicense: CC BY-SA 4.0


问:
How to get into each element in a nested list and compare it with the equivalent in all elements in another list?
I need to get into each element in a nested list and compare it with the equivalent in all elements in another list.

I have two nested lists:

LB=

[[1, 0, 1, 0],

[1, 1, 1, 1],

[0, 0, 1, 0]]

LK=

[[1, 0, 1, 0],

[0, 0, 1, 1],

[1, 1, 1, 1],

[0, 0, 1, 0],

[1, 1, 0, 0],

[0, 0, 0, 0]
]

Analysis flow:

I take the first sublist from LK (i.e., [1, 0, 1, 0]) and compare its individual elements (i.e., 1, 0, 1, 0) with subsequent elements from the sublists LB [1, 0, 1, 0], [1, 1, 1, 1], and [0, 0, 1, 0].
I then take the second sublist from LK (i.e., [0, 0, 1, 1]) and compare its individual elements (i.e., 0, 0, 1, 1) with the subsequent elements from the LB sublist [1, 0, 1, 0], [1, 1, 1, 1, 1], and [0, 0, 1, 0]
I then take the third sublist from LK (i.e., [1, 1, 1, 1]) and compare its individual elements (i.e., 1, 1, 1, 1) with the subsequent elements from the LB sublist [1, 0, 1, 0], [1, 1, 1, 1, 1], and [0, 0, 1, 0]

Here is my attempt at the code, but I know it doesn't work properly and doesn't contain all the conditions.

```<code>for i in LK, LB:
    for j in i:
        while j < (len(LK)-1):
            if j == 0:
                j += 1
            elif j != 0:
                i += 1
            else:
                print(LB[i])
</code>```

Additional conditions:

if a given element in a list in LK is equal to 0 and the digit at the same position in LB is also equal to 0 then proceed to compare the next digit in the given list. When you get to the end of the sublist in the LK list, i.e. you pass [1, 0, 1, 0] and the condition with zeroes is fulfilled, write me this element from the LB list

if given element in the list in LK is equal 0, but digit in the same position in the list LB is not equal 0 then skip this case and check another sublist from LB

if there is no element 0 in the list LK (list [1, 1, 1, 1]) then write a sublist from LB

We perform such an iteration for all the elements in the list LB comparing them with the sublists from LK.

In the analyzed example during the comparison:

the first sublist from LK ([1, 0, 1, 0]) => should be extracted from the list LB: [1, 0, 1, 0] and [0, 0, 1, 0]

the second sublist from LK ([0, 0, 1, 1]) => should be printed from the list LB: [0, 0, 1, 0]

the third sublist from LK ([1, 1, 1, 1, 1]) => should be printed from the lists LB: [1, 0, 1, 0], [1, 1, 1, 1] and [0, 0, 1, 0]

the fourth sublist from LK ([0, 0, 1, 0]) => should be printed from the list LB: [0, 0, 1, 0]

the fifth sublist from LK ([1, 1, 0, 0]) => no element should be written out from the list LB

sixth sublist from LK ([0, 0, 0, 0]) => no element should be written out from the list LB

Output:
Displayed LB sublists that meet the conditions (LB sublists can be displayed in several sectors)

答:
I'm not clear on what you want to do if a sublist from LK matches more than one sublist from LB, but if you only one copy, then I think this does what you want:

```<code>[B_list for B_list in LB if any(
    all(
        k_item!=0 or b_item==0 for k_item, b_item in zip(B_list, K_list)
        )
    for K_list in LK
    )
]
</code>```

Line 1 iterates over LB and Line 5 iterates over LK. Line 3 checks whether the corresponding elements of the chosen sublists match at a particular location, and Line 2 checks whether they match throughout the sublists. Then the any at the end of Line 1 checks whether, for a particular sublist of LB, there is any sublist of LK that works. So this returns all sublists of LB for which there is any sublist of LK for which for all locations the corresponding elements match.

Output:

```<code>[[1, 0, 1, 0], [1, 1, 1, 1], [0, 0, 1, 0]]
</code>```

Body:
I need to get into each element in a nested list and compare it with the equivalent in all elements in another list.

I have two nested lists:

LB=

[[1, 0, 1, 0],

[1, 1, 1, 1],

[0, 0, 1, 0]]

LK=

[[1, 0, 1, 0],

[0, 0, 1, 1],

[1, 1, 1, 1],

[0, 0, 1, 0],

[1, 1, 0, 0],

[0, 0, 0, 0]
]

Analysis flow:

I take the first sublist from LK (i.e., [1, 0, 1, 0]) and compare its individual elements (i.e., 1, 0, 1, 0) with subsequent elements from the sublists LB [1, 0, 1, 0], [1, 1, 1, 1], and [0, 0, 1, 0].
I then take the second sublist from LK (i.e., [0, 0, 1, 1]) and compare its individual elements (i.e., 0, 0, 1, 1) with the subsequent elements from the LB sublist [1, 0, 1, 0], [1, 1, 1, 1, 1], and [0, 0, 1, 0]
I then take the third sublist from LK (i.e., [1, 1, 1, 1]) and compare its individual elements (i.e., 1, 1, 1, 1) with the subsequent elements from the LB sublist [1, 0, 1, 0], [1, 1, 1, 1, 1], and [0, 0, 1, 0]

Here is my attempt at the code, but I know it doesn't work properly and doesn't contain all the conditions.

for i in LK, LB:
    for j in i:
        while j < (len(LK)-1):
            if j == 0:
                j += 1
            elif j != 0:
                i += 1
            else:
                print(LB[i])

Additional conditions:

if a given element in a list in LK is equal to 0 and the digit at the same position in LB is also equal to 0 then proceed to compare the next digit in the given list. When you get to the end of the sublist in the LK list, i.e. you pass [1, 0, 1, 0] and the condition with zeroes is fulfilled, write me this element from the LB list

if given element in the list in LK is equal 0, but digit in the same position in the list LB is not equal 0 then skip this case and check another sublist from LB

if there is no element 0 in the list LK (list [1, 1, 1, 1]) then write a sublist from LB

We perform such an iteration for all the elements in the list LB comparing them with the sublists from LK.

In the analyzed example during the comparison:

the first sublist from LK ([1, 0, 1, 0]) => should be extracted from the list LB: [1, 0, 1, 0] and [0, 0, 1, 0]

the second sublist from LK ([0, 0, 1, 1]) => should be printed from the list LB: [0, 0, 1, 0]

the third sublist from LK ([1, 1, 1, 1, 1]) => should be printed from the lists LB: [1, 0, 1, 0], [1, 1, 1, 1] and [0, 0, 1, 0]

the fourth sublist from LK ([0, 0, 1, 0]) => should be printed from the list LB: [0, 0, 1, 0]

the fifth sublist from LK ([1, 1, 0, 0]) => no element should be written out from the list LB

sixth sublist from LK ([0, 0, 0, 0]) => no element should be written out from the list LB

Output:
Displayed LB sublists that meet the conditions (LB sublists can be displayed in several sectors)

Body:
I'm not clear on what you want to do if a sublist from LK matches more than one sublist from LB, but if you only one copy, then I think this does what you want:

[B_list for B_list in LB if any(
    all(
        k_item!=0 or b_item==0 for k_item, b_item in zip(B_list, K_list)
        )
    for K_list in LK
    )
]

Line 1 iterates over LB and Line 5 iterates over LK. Line 3 checks whether the corresponding elements of the chosen sublists match at a particular location, and Line 2 checks whether they match throughout the sublists. Then the any at the end of Line 1 checks whether, for a particular sublist of LB, there is any sublist of LK that works. So this returns all sublists of LB for which there is any sublist of LK for which for all locations the corresponding elements match.

Output:

[[1, 0, 1, 0], [1, 1, 1, 1], [0, 0, 1, 0]]


问:
Cell Renderer a custom componenent, keeps getting "Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'."
When I try to render custom element using cell render,

here is my component: Action.jsx

```<code>import React from 'react';

export default (props) => (
    <div>
        <button
            class="action-button cancel">
            cancel
        </button>
    </div>
);
</code>```

here are my grid options and import:

```<code>import AcRenderer from './Action.jsx'
...
const gridOptions = {
    rowData: renderdata(),
    columnDefs: [
      {
        headerName: "action",
        cellRenderer: AcRenderer,
        editable: false,
        colId: "action",
        filter: false,
        minWidth: 220
      }
    ],
</code>```

but I keep getting this error:

"Uncaught TypeError: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'."

Does anyone know why?

with many thanks!!

答:
probloem sovled.

I have no idea somewhow i was reading 27.0.0 version of document but actually using 26.2. In this version, it support you write a functional component and use is directly.(when I test, there is a new release 27.0.1 in 6 mins ago, but after test, there are issues loged on console, so decided to use back to 26.2)

But in 26.2 version, you have to export in string or import it using frameworkComponents inside the ag grid options, after that you can use you component.

To be honest, can we have some warning like: you are reading which version of document? I saw 27.0.0 was released on 08 Feb but the project started several days  early than that, during these days I didn't even notice that there is a huge version release...

sorry about my complain(this issue really waste a lot of time) but hope my findings can help!

Body:
When I try to render custom element using cell render,

here is my component: Action.jsx

import React from 'react';

export default (props) => (

        <button
            class="action-button cancel">
            cancel
        </button>

);

here are my grid options and import:

import AcRenderer from './Action.jsx'
...
const gridOptions = {
    rowData: renderdata(),
    columnDefs: [
      {
        headerName: "action",
        cellRenderer: AcRenderer,
        editable: false,
        colId: "action",
        filter: false,
        minWidth: 220
      }
    ],

but I keep getting this error:

"Uncaught TypeError: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'."

Does anyone know why?

with many thanks!!


问:
Server not receiving HTTP requests from Client
First a quick preface I think may be helpful: I am new to splitting my client and server into separate web apps. My previous apps have all had my server.js at the root level in my directory and the client (typically a create-react-app) in a /client folder.

What I wanted to do: Host a single express.js server on the web which multiple other web applications could make requests to.

I did the first part using an express server and aws elastic beanstalk.

server.js

require('dotenv').config()
const express = require('express');
const app = express();
const cors = require('cors');
const PORT = process.env.PORT || 5000;
const Mongoose = require('mongoose');
const { Sequelize } = require("sequelize");

//ROUTES
const APIUser = require('./routes/api/mongo/api-user');
more routes...

//INITIATE DATA MAPPING CONNECTIONS START
Mongoose.connect(
    process.env.MONGO_URI,
    { useNewUrlParser: true, useUnifiedTopology: true },
    console.log("connected to MongoDB")
);

const Postgres = new Sequelize(process.env.PG_CONN_STRING);

try {
    Postgres.authenticate()
        .then(console.log("connected to Postgres"));
} catch {
    console.log("Postgres connection failed")
}
//INITIATE DATA MAPPING CONNECTIONS END

//middleware
app.use(cors())
more middleware...

//home route
app.get('/api', (req, res) => {
    console.log('RECEIVED REQ to [production]/api/')
    res.status(200).send('models api home').end();
})

//all other routes
app.use('/api/user', APIUser);
more route definitions...

//launch
app.listen(PORT, () => console.log(`listening on port ${PORT}`));
```
<p>The log file for successful boot up on aws: https://imgur.com/vLgdaxK</p>
<p>At first glance it seemed to work as my postman requests were working. Status 200 with appropriate response: https://imgur.com/VH4eHzH</p>
<p>Next I tested this from one of my actual clients <strong>in localhost</strong>. Here is one of my react client's api util files where axios calls are made to the backend:</p>
<pre class="lang-js prettyprint-override"><code>import { PROXY_URL } from '../../config';
import { axiosInstance } from '../util';

const axiosProxy = axios.create({baseURL: PROXY_URL}); //this was the most reliable way I found to proxy requests to the server

export const setAuthToken = () => {
    const route = "/api/authorization/new-token";
    console.log("SENDING REQ TO: " + PROXY_URL + route)

    return axiosProxy.post(route)
}

export const authorize = clientsecret => {
    const route = "/api/authorization/authorize-survey-analytics-client";
    console.log("SENDING REQ TO: " + PROXY_URL + route)

    return axiosProxy.post(route, { clientsecret })
}
</code>```

Once again it worked... or rather I eventually got it to work: https://imgur.com/c2rPuoc

So I figured all was well now but when I tried using the live version of the client the request failed somewhere.

in summary the live api works when requests are made from postman or localhost but doesn't respond when requests are made from a live client https://imgur.com/kOk2RWf

I have confirmed that the requests made from the live client do not make it to the live server (by making requests from a live client and then checking the aws live server logs).

I am not receiving any Cors or Cross-Origin-Access errors and the requests from the live client to the live server don't throw any loud errors, I just eventually get a net::ERR_CONNECTION_TIMED_OUT. Any ideas where I can look for issues or is there more code I could share?

Thank you!

答:
Add a console.log(PROXY_URL) in your client application and check your browser console if that's logged correctly.

If it works on your local client build, and through POSTMAN, then your backend api is probably good. I highly suspect that your env variables are not being set. If PROXY_URL is an emplty string, your axios requests will be routed back to the origin of your client. But I assume they have different origins since you mention that they're separate apps.

Remember environment variables need to prefixed with REACT_APP_ and in a production build they have to be available at build time (wherever you perform npm run build)

Body:
First a quick preface I think may be helpful: I am new to splitting my client and server into separate web apps. My previous apps have all had my server.js at the root level in my directory and the client (typically a create-react-app) in a /client folder.

What I wanted to do: Host a single express.js server on the web which multiple other web applications could make requests to.

I did the first part using an express server and aws elastic beanstalk.

server.js

require('dotenv').config()
const express = require('express');
const app = express();
const cors = require('cors');
const PORT = process.env.PORT || 5000;
const Mongoose = require('mongoose');
const { Sequelize } = require("sequelize");

//ROUTES
const APIUser = require('./routes/api/mongo/api-user');
more routes...

//INITIATE DATA MAPPING CONNECTIONS START
Mongoose.connect(
    process.env.MONGO_URI,
    { useNewUrlParser: true, useUnifiedTopology: true },
    console.log("connected to MongoDB")
);

const Postgres = new Sequelize(process.env.PG_CONN_STRING);

try {
    Postgres.authenticate()
        .then(console.log("connected to Postgres"));
} catch {
    console.log("Postgres connection failed")
}
//INITIATE DATA MAPPING CONNECTIONS END

//middleware
app.use(cors())
more middleware...

//home route
app.get('/api', (req, res) => {
    console.log('RECEIVED REQ to [production]/api/')
    res.status(200).send('models api home').end();
})

//all other routes
app.use('/api/user', APIUser);
more route definitions...

//launch
app.listen(PORT, () => console.log(`listening on port ${PORT}`));

The log file for successful boot up on aws: https://imgur.com/vLgdaxK

At first glance it seemed to work as my postman requests were working. Status 200 with appropriate response: https://imgur.com/VH4eHzH

Next I tested this from one of my actual clients in localhost. Here is one of my react client's api util files where axios calls are made to the backend:

import { PROXY_URL } from '../../config';
import { axiosInstance } from '../util';

const axiosProxy = axios.create({baseURL: PROXY_URL}); //this was the most reliable way I found to proxy requests to the server

export const setAuthToken = () => {
    const route = "/api/authorization/new-token";
    console.log("SENDING REQ TO: " + PROXY_URL + route)

    return axiosProxy.post(route)
}

export const authorize = clientsecret => {
    const route = "/api/authorization/authorize-survey-analytics-client";
    console.log("SENDING REQ TO: " + PROXY_URL + route)

    return axiosProxy.post(route, { clientsecret })
}

Once again it worked... or rather I eventually got it to work: https://imgur.com/c2rPuoc

So I figured all was well now but when I tried using the live version of the client the request failed somewhere.

in summary the live api works when requests are made from postman or localhost but doesn't respond when requests are made from a live client https://imgur.com/kOk2RWf

I have confirmed that the requests made from the live client do not make it to the live server (by making requests from a live client and then checking the aws live server logs).

I am not receiving any Cors or Cross-Origin-Access errors and the requests from the live client to the live server don't throw any loud errors, I just eventually get a net::ERR_CONNECTION_TIMED_OUT. Any ideas where I can look for issues or is there more code I could share?

Thank you!


问:
css :not problem when body or * is specified in style
I'm learning css and trying to change background-color of all html except one div tag using :not element.

When i put like body:not(.one) it is changing background-color of whole html but not excluding the div mentioned in :not condition. Same problem if i use *:not(.one) Am i doing correct?

```<code><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<style type="text/css">

body:not(.one)
{

background-color:blue;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<div class="one">
this is first div
</div>
<div >
this is second div
</div>
<p>
this  is a paragraph
</p>

</body>
</html>
</code>```

答:
The background color of your div is transparent. It looks to me like you're setting the body color and then expecting the div to be white or such like.

Given the CSS rule you're using, it's only styling the body tag anyway. You don't need to tell it not to style the div because it wasn't going to anyway.

The not() selector comes in handy when you want to style all divs for example, except ones that have a given class, such as:

```<code>div:not(.items){ /* some styles */}
</code>```

This makes sens because there may be many div that we want to style, except div with the class items.

Your example in the question doesn't make so much sense because you're styling the body of which there's only one.

Your statement actually says:

Style all body tags except any body tag that has the class name one.

Body:
I'm learning css and trying to change background-color of all html except one div tag using :not element.

When i put like body:not(.one) it is changing background-color of whole html but not excluding the div mentioned in :not condition. Same problem if i use *:not(.one) Am i doing correct?

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>

this is first div

this is second div

this  is a paragraph

Body:
The background color of your div is transparent. It looks to me like you're setting the body color and then expecting the div to be white or such like.

Given the CSS rule you're using, it's only styling the body tag anyway. You don't need to tell it not to style the div because it wasn't going to anyway.

The not() selector comes in handy when you want to style all divs for example, except ones that have a given class, such as:

div:not(.items){ /* some styles */}

This makes sens because there may be many div that we want to style, except div with the class items.

Your example in the question doesn't make so much sense because you're styling the body of which there's only one.

Your statement actually says:

Style all body tags except any body tag that has the class name one.


问:
Filter out data at the end of each month using pd.Period
I have a pandas data frame and my goal is to filter out data at the end of each month (i.e. 2021-12-31, 2022-01-31, etc).

I have 2 sets of code and 1 works but the other doesn't even though they the type(criteria) is the same - string.

Works:

```<code>df_monthly = df[df.index == str(dt.date(2022,1,31))]
</code>```

Does not work:

```<code>df_monthly = df[df.index == str(pd.Period(df.index, freq='M').end_time.date())]
</code>```

The 2nd line returns this error:
ValueError: Value must be Period, string, integer, or datetime

Anyone knows why this is the case and how do I remedy? I'm hoping to be able to proceed using pd.Period() instead of dt.date().

Many thanks!

答:
If the index is a DatetimeIndex, you can call .to_period followed by .to_timestamp on the index to do this:

```<code>df_monthly = df.loc[df.index == df.index.to_period('M').to_timestamp('M')]
</code>```

If the index needs to be converted first, you can use pd.to_datetime (and optionally set errors='coerce' to handle invalid dates)

Another succinct option is to use offsets.MonthEnd:

```<code>df_monthly = df.loc[df.index == df.index + pd.offsets.MonthEnd(0)]
</code>```

Body:
I have a pandas data frame and my goal is to filter out data at the end of each month (i.e. 2021-12-31, 2022-01-31, etc).

I have 2 sets of code and 1 works but the other doesn't even though they the type(criteria) is the same - string.

Works:

df_monthly = df[df.index == str(dt.date(2022,1,31))]

Does not work:

df_monthly = df[df.index == str(pd.Period(df.index, freq='M').end_time.date())]

The 2nd line returns this error:
ValueError: Value must be Period, string, integer, or datetime

Anyone knows why this is the case and how do I remedy? I'm hoping to be able to proceed using pd.Period() instead of dt.date().

Many thanks!

Body:
If the index is a DatetimeIndex, you can call .to_period followed by .to_timestamp on the index to do this:

df_monthly = df.loc[df.index == df.index.to_period('M').to_timestamp('M')]

If the index needs to be converted first, you can use pd.to_datetime (and optionally set errors='coerce' to handle invalid dates)

Another succinct option is to use offsets.MonthEnd:

df_monthly = df.loc[df.index == df.index + pd.offsets.MonthEnd(0)]


问:
Ruby on Rails - Composer
i am new to the world of programming and i started programming with ruby on rails on ubuntu 20.4 through virtual machine. I'm trying to make an application with composer. only every time I type: rails new myapplication -m https://raw.github.com/RailsApps/rails-composer/master/composer.rb ; I get the following message: Rails 7.0.2.2 is not supported. Use Rails 4.1 or newer. I installed ruby on rails from rvm and these are my versions:

```<code>$ rails -v: Rails 7.0.2.2

$ ruby -v: ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux]

$ rvm: rvm 1.29.12 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]

$ gem list: rails (7.0.2.2, 4.1.0)
</code>```

I already tried to uninstall this version 7 of rails and install the version that is requested but even so when I create a new application changing the name or overwriting the one I had already created, the same error occurs.

thanks for the help in advance!

答:
If you search that composer code, you should find this:

# this application template only supports Rails version 4.1 and newer
case Rails::VERSION::MAJOR.to_s
when "5"
  say_wizard "You are using Rails version #{Rails::VERSION::STRING}. Please report any issues."
when "3"
  say_wizard "You are using Rails version #{Rails::VERSION::STRING} which is not supported. Use Rails 4.1 or newer."
  raise StandardError.new "Rails #{Rails::VERSION::STRING} is not supported. Use Rails 4.1 or newer."
when "4"
  case Rails::VERSION::MINOR.to_s
  when "0"
    say_wizard "You are using Rails version #{Rails::VERSION::STRING} which is not supported. Use Rails 4.1 or newer."
    raise StandardError.new "Rails #{Rails::VERSION::STRING} is not supported. Use Rails 4.1 or newer."
  end
else
  say_wizard "You are using Rails version #{Rails::VERSION::STRING} which is not supported. Use Rails 4.1 or newer."
  raise StandardError.new "Rails #{Rails::VERSION::STRING} is not supported. Use Rails 4.1 or newer."
end
```

The author did a poor job of writing that case statement and error message. When that case statement runs on your setup, it's doing this:

Is this rails version 5? No? Ok.

Is this rails version 3? No? Ok.

Is this rails version 4? No? Ok.

Well then it must be a rails version before 4, because we all know numbers never grow past 5! ¯\(ツ)/¯

Use RVM to install Rails version 5, or choose a different project.

Title: Ruby on Rails - Composer

Body:
i am new to the world of programming and i started programming with ruby on rails on ubuntu 20.4 through virtual machine. I'm trying to make an application with composer. only every time I type: rails new myapplication -m https://raw.github.com/RailsApps/rails-composer/master/composer.rb ; I get the following message: Rails 7.0.2.2 is not supported. Use Rails 4.1 or newer. I installed ruby on rails from rvm and these are my versions:

$ rails -v: Rails 7.0.2.2

$ ruby -v: ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux]

$ rvm: rvm 1.29.12 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]

$ gem list: rails (7.0.2.2, 4.1.0)

I already tried to uninstall this version 7 of rails and install the version that is requested but even so when I create a new application changing the name or overwriting the one I had already created, the same error occurs.

thanks for the help in advance!

Body:
If you search that composer code, you should find this:

# this application template only supports Rails version 4.1 and newer
case Rails::VERSION::MAJOR.to_s
when "5"
  say_wizard "You are using Rails version #{Rails::VERSION::STRING}. Please report any issues."
when "3"
  say_wizard "You are using Rails version #{Rails::VERSION::STRING} which is not supported. Use Rails 4.1 or newer."
  raise StandardError.new "Rails #{Rails::VERSION::STRING} is not supported. Use Rails 4.1 or newer."
when "4"
  case Rails::VERSION::MINOR.to_s
  when "0"
    say_wizard "You are using Rails version #{Rails::VERSION::STRING} which is not supported. Use Rails 4.1 or newer."
    raise StandardError.new "Rails #{Rails::VERSION::STRING} is not supported. Use Rails 4.1 or newer."
  end
else
  say_wizard "You are using Rails version #{Rails::VERSION::STRING} which is not supported. Use Rails 4.1 or newer."
  raise StandardError.new "Rails #{Rails::VERSION::STRING} is not supported. Use Rails 4.1 or newer."
end

The author did a poor job of writing that case statement and error message. When that case statement runs on your setup, it's doing this:

Is this rails version 5? No? Ok.

Is this rails version 3? No? Ok.

Is this rails version 4? No? Ok.

Well then it must be a rails version before 4, because we all know numbers never grow past 5! ¯\(ツ)/¯

Use RVM to install Rails version 5, or choose a different project.


问:
'Invalid Format' - Telegram BOT Token API - Telegram.Bot Package
how're going?

I'm trying to start a Telegram Bot using Telegram.Bot package from NuGet on .NET Framework, and the bellow error is tanking place:Error Telegram.Bot

This only happens with new bots created on Telegram Bot Father using the API Token to start the BOT and not happens with old BOTs.

Anyone can help me?

答:
Same problem, but, as the warning messages also say while compiling the code, old versions will not work in future.
I advise you to check the new version (17.0.0 is the last).
Watch this video to see an example:
https://youtu.be/EJIur-6RqPY

There is also the Migration Guide:
https://telegrambots.github.io/book/Migration-Guide-to-Version-17.x.html


问:
iPad Launch image landscape
I keep getting a warning that my ipad launch image landscape isnt 1024x748, while it actually is that size. When i do compile with the 'wrong' size, it gives me a bloated portrait image.</p>

答:
@MaikelS - What version of Xcode are you using?

In Xcode 4.0 on Snow Leopard my landscape launch image would throw a warning even though it would load in the app just fine. The warning was actually a triangular yellow caution image superimposed over the landscape launch image (in Xcode select your Project, then select the Target, the select Summary tab and scroll to see launch images).

FWIW, I've since moved to Xcode 4.1 on Lion and the warning has disappeared.

Title: iPad Launch image landscape


问:
TWO SUM PROBLEM IN JAVA - I coded the below code but unable to find the problem in this
Given an array of integers nums and an integer target, return indices    of the two numbers such that they add up to target.
You may assume that each input would have exactly one solution, and    you may not use the same element twice.
You can return the answer in any order.
Example 1:
Input: nums = [2,7,11,15], target = 9 Output: [0,1] Explanation:    Because nums[0] + nums[1] == 9, we return [0, 1].

Hi Team,

Above is my problem statement  and below is the code i coded.

```<code>
                           Online Java Compiler.
               Code, Compile, Run and Debug java program online. Write your code in this editor and press "Run" button to execute it.
*******************************************************************************/
public class Main {
    public static void main(String[] args) {
        int[] nums={2,7,8,0};
        int target=9;

        int s=0;
        for(int i=0;i<nums.length;i++)
        {
            for(int j=i+1;j<nums.length;j++)
            {
                s=s+nums[i][j];
            }
            if(s==target)
            {
                System.out.print("["+i+","+j+"]");
            }
        }
    }
}
</code>```

I am unable to understand what's the problem with compilation ,could    anyone help!->Main.java:20: error: array required, but int found    s=s+nums[i][j];    it shows this errorenter code here

答:
In the line s=s+nums[i][j]; you are accessing nums as 2D array.

But you defined the variable nums as a 1D array.

Reply if you need more help.

Body:
Given an array of integers nums and an integer target, return indices    of the two numbers such that they add up to target.
You may assume that each input would have exactly one solution, and    you may not use the same element twice.
You can return the answer in any order.
Example 1:
Input: nums = [2,7,11,15], target = 9 Output: [0,1] Explanation:    Because nums[0] + nums[1] == 9, we return [0, 1].

Hi Team,

Above is my problem statement  and below is the code i coded.

                           Online Java Compiler.
               Code, Compile, Run and Debug java program online. Write your code in this editor and press "Run" button to execute it.
*******************************************************************************/
public class Main {
    public static void main(String[] args) {
        int[] nums={2,7,8,0};
        int target=9;

        int s=0;
        for(int i=0;i<nums.length;i++)
        {
            for(int j=i+1;j<nums.length;j++)
            {
                s=s+nums[i][j];
            }
            if(s==target)
            {
                System.out.print("["+i+","+j+"]");
            }
        }
    }
}

I am unable to understand what's the problem with compilation ,could    anyone help!->Main.java:20: error: array required, but int found    s=s+nums[i][j];    it shows this errorenter code here