CodeWar1008
CodeWar Practice Summary
K8
Calculate average
两种情况,数组存在求平均值,不存在为空则直接返回0
判断数组是否为0
/* The Array is NULL*/
array == false;
array.length == 0;
array == 0;
/*The code on the top*/
function find_average(array) {
var sum = array.reduce((a, b) => a + b, 0)
原创
2021-10-08 16:05:01 ·
71 阅读 ·
0 评论