diff --git a/package.json b/package.json index ce06995..eb0136d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "swgoh-api-swgohgg", - "version": "0.0.3", + "version": "0.0.4", "description": "SWGoH helper API for swgoh.gg", "main": "index.js", "keywords": [ diff --git a/swgohgg-api.js b/swgohgg-api.js index 7aba71a..ed57a07 100644 --- a/swgohgg-api.js +++ b/swgohgg-api.js @@ -575,16 +575,9 @@ class SwgohGGApi { static getPlayerUnitFromUnits(player, searchName) { var result; - // loop over characters - for (var i = 0; i < player.units.length; i++) { - const unit = player.units[i].data; + const playerUnit = player.units.find(unit => unit.data.name.toLowerCase() == searchName.toLowerCase()); - // test for name (ignoring case) - if (unit.name.toLowerCase() == searchName.toLowerCase()) { - result = unit; - break; - } - } + if (playerUnit) result = playerUnit.data; return result; }