val is a parameter, and a value is passed every time you click, but the array does not accumulate. I don’t know why.
typecho2017-06-26 11:00:45
Because the array you accumulate is new every time, arr
is reassigned to ['s', 'd']
every time.
天蓬老师2017-06-26 11:00:45
Just define var arr = [] outside the current function, similar to this:
var arr = ['s', 'd']
function addArr(val){
arr.push(val)
}