here is my code pushing data to an array variable, but I am getting a blank array. what am I doing wrong?
let users = []
//looping ajax response here
for(var i = 0; i < response.length; i++ ) {
users.push(response[i].user_name)
}
when I run console.log this is what I got
console.log(users) // Array[]
response.lengthbefore the loop .... though, considering the comment "looping ajax response here", your issue is probably with how you're (not) dealing with asynchronous responsesconsole.log(response.length) // Array(31)console.log(response.length)outputsArray(31)? hint: no, it doesn't