friend
here is the index of your array, not the value at the index
var room = 'userid'+friends[friend]+'friends';
Plus when looping through an array I don't recommend to use for..in loops, you can use Array.prototype.map
or plain for loop with the length of your array
Array map example:
var friends=['2','3'];
console.log(friends);
var rooms= friends.map(function (friend, index) {
return 'userid' + friend + 'friends';
});
console.log(rooms);
Plain for loop:
var friends=['2','3'];
console.log(friends);
var rooms=[];
for (var i = 0, l = friends.length; i < l; ++i) {
var room = 'userid' + friends[i] + 'friends';
console.log(room);
rooms.push(room);
}
console.log(rooms);