I called a function to count, and I would like to return the data as an array and use it then, how can I do the same . where this returned arr is been stored, so I can use t in main code
var newArr =[]
countData(jsonData).then(function (res) {
console.log(arr)
console.log('end')
})
function countData(jsonData){
var five=0, two =0
for(var i in jsonData){
console.log(jsonData)
if(jsonData.num == '5'){
five++;
}
else{
two++;
}
}//for
var arr =[]
arr[0]=five
arr[1]=two
return arr
}//function