jquery ajax – Rest API to consult the list of user information

I'm experimenting with some API Rest code. My knowledge of javascript and jquery is basic, but I know enough to get what I need. Generally through trial and error.
This is what I am trying to do:

  1. Use of "/ _api / web / sitegroups / getByName (& # 39; Intranet Team & # 39;) / users" to return the ID of all members of that permission group.
  2. Then run those IDs through "/ teams / Sales / _api / web / lists / getbytitle (& # 39; List of user information & # 39;) / items (" + items[i].Id + ")" to obtain the Name, Office and other details of each member of the permission group.
  3. Finally, print the details of the User Information List in divs by Office location.

The problem I have is in step 3. I am doing something wrong with my conditional and is returning all users regardless of the location. The following is my sample code:

$ .ajax ({
url: _spPageContextInfo.webAbsoluteUrl + "/ _api / web / sitegroups / getByName (& # 39; Intranet Team & # 39;) / users",
type: "GET",
headers: {"accept": "application / json; odata = verbose"},
success: function (data) {
var items = data.d.results;
else {
for (var i = 0; i <items.length; i ++) {
$ .ajax ({
url: "/ teams / Sales / _api / web / lists / getbytitle (& # 39; List of user information & # 39;) / items (" + items[i].Id + ")",
Method: "GET",
headers: {"Accept": "application / json; odata = verbose"},
success: function (data) {
var userOffice = data.d.Office;
console.log (userOffice);
yes (userOffice = & # 39; North York & # 39;) {
$ (& # 39; # NorthYork & # 39;). Append (& # 39;

& # 39; + data.d.Title + & # 39; - & # 39; + data.d.Office + & # 39;

& # 39;); } } error: function (data) { alert (JSON.stringify (data)); } }); } }}

Any help would be greatly appreciated.
Martin