From f27aab1d3de6fbff2107ee0a2d41e1b7c2924c7b Mon Sep 17 00:00:00 2001 From: Amelia <9247739-limesey@users.noreply.gitlab.com> Date: Sun, 5 Jun 2022 18:35:23 +0100 Subject: [PATCH] Deal with empty strings being inserted into the key --- src/scrapers/euromilhoes.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/scrapers/euromilhoes.ts b/src/scrapers/euromilhoes.ts index c1990d1..5027d57 100644 --- a/src/scrapers/euromilhoes.ts +++ b/src/scrapers/euromilhoes.ts @@ -42,6 +42,22 @@ function getKey(element: cheerio.Cheerio) { const numbers = splitKey[0].split(" "); const stars = splitKey[1].split(" "); + // Not sure why, but an empty string is being inserted into the array + numbers.forEach((value, i) => { + console.log(value == ""); + if (value == "") { + numbers.splice(i, i); + } + }); + + stars.forEach((value, i) => { + if (value == "") { + numbers.splice(i, i); + } + }); + + console.log(stars); + return { numbers: numbers, stars: stars }; }