Answer the question
In order to leave comments, you need to log in
We get friends hiding you, why does it only display the last value from the loop?
I get a list of friends from the user with id 33919072, then running through the loop, I get a list of friends from each of his friends and look for id 33919072 in it -> if I don’t find it, then I display the ID that was not found in the list id 33919072.
If there is a hopeless situation, how can you do it the right way...
var userId = 33919072;
var i = '';
var f = '';
var GetUserName = function () {
VK.api('friends.get', {'user_id' : userId}, function(data) {
for (i = 0, l = data.response.length; i < l; i++) {
var script = document.createElement('SCRIPT');
script.src = "https://api.vk.com/method/friends.get?user_id="+ data.response[i] +"&v=5.50&callback=callbackFunc";
document.getElementsByTagName("head")[0].appendChild(script);
f = data.response[i];
}
});
};
function callbackFunc(result) {
if (result.response.items.indexOf(userId) === -1) {
console.log(f);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question