From 46666247b2a2c65204f1f7ee1cbac3ac5811edde Mon Sep 17 00:00:00 2001 From: Kevin Nowaczyk Date: Wed, 17 Jul 2024 07:56:49 -0400 Subject: [PATCH] Update buildingpart.js --- src/buildingpart.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/buildingpart.js b/src/buildingpart.js index 098081f..e61a4f1 100644 --- a/src/buildingpart.js +++ b/src/buildingpart.js @@ -416,7 +416,11 @@ class BuildingPart { */ static cardinalToDegree(cardinal) { const cardinalUpperCase = `${cardinal}`.toUpperCase(); - let degreesTimesTwo = 'N NNE NE ENE E ESE SE SSE S SSW SW WSW W WNW NW NNW'.split(' ').indexOf(cardinalUpperCase) * 45; + const index = 'N NNE NE ENE E ESE SE SSE S SSW SW WSW W WNW NW NNW'.split(' ').indexOf(cardinalUpperCase); + if (index === -1) { + return undefined; + } + const degreesTimesTwo = index * 45; // integer floor return degreesTimesTwo % 2 === 0 ? degreesTimesTwo / 2 : (degreesTimesTwo - 1) / 2; }