Following is a JSON output from an API, I've had trouble trying to compare the "last_save" variables, and if a profile has a larger "last_save" value, set the "profile_id" as a variable. (Im fairly new to java script, sorry if I use incorrect terminology)
Here is the code:
function profileID(){
    console.log("Running profileID.")
    var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
      if (this.readyState == 4 && this.status == 200) {
       rawJsonText = this.responseText;
       var parsedText = JSON.parse(rawJsonText);
       console.log(parsedText)
       console.log(playerUUID)
       lastPlayedIslandID = parsedText[0].last_save
       lastPlayedProfileName = parsedText.profile_id
       console.log(nameMC+"'s island ID : "+lastPlayedIslandID);
       console.log(nameMC+"'s island name : "+lastPlayedProfileName);
       slayerZombie();
      }
    };
    xhttp.open("GET", slothpixelAPI+"skyblock/profiles/"+nameMC, true);
    xhttp.send();
}
This is the JSON output from the API:
{
  "5ab88f71d10747aabf643e666c9933b1": {
    "profile_id": "5ab88f71d10747aabf643e666c9933b1",
    "cute_name": "Grapes",
    "first_join": 1578113432038,
    "last_save": 1582337480211,
    "collections_unlocked": 0,
    "members": [
      "4878f8a455e84956b19d4873d837ab93"
    ]
  },
  "4878f8a455e84956b19d4873d837ab93": {
    "profile_id": "4878f8a455e84956b19d4873d837ab93",
    "cute_name": "Coconut",
    "first_join": 1560932868602,
    "last_save": 1583315330184,
    "collections_unlocked": 59,
    "members": [
      "8d32864b3a364035922dd84d5247f483",
      "4878f8a455e84956b19d4873d837ab93"
    ]
  }
}
Thanks
 
     
    